Part Number Hot Search : 
MAX6064 LPV7215 S5565 C100LVEL C8225 000950 40310 LX9506
Product Description
Full Text Search
 

To Download AT83SND2C-7FTUL Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  rev. 4341e?mp3?06/05 features ? mpeg i/ii-layer 3 hardwired decoder ? stand-alone mp3 decoder ? 48, 44.1, 32, 24, 22.05, 16 khz sampling frequency ? separated digital volume control on left and right channels (software control using 31 steps) ? bass, medium, and treble control (31 steps) ? bass boost sound effect ? ancillary data extraction ? crc error and mpeg frame synchronization indicators ? 20-bit stereo audio dac ? 93 db snr playback stereo channel ? 32 ohm/ 20 mw stereo headset drivers ? stereo line level input, diffe rential mono auxiliary input ? programmable audio output for inte rfacing with external audio system ? pcm format compatible ?i 2 s format compatible ? mono audio power amplifier ? 440mw on 8 ohms load ? 8-bit mcu c51 core based (f max = 20 mhz) ? 2304 bytes of internal ram ? 64k bytes of code memory ? at89c51snd2c: flash (100k erase/write cycles) ? at83snd2c: rom ? 4k bytes of boot flash memory (at89c51snd2c) ? isp: download from usb (s tandard) or uart (option) ? usb rev 1.1 controller ? full speed data transmission ? built-in pll ? mp3 audio clocks ?usb clock ? multimedia card ? interface compatibility ? atmel dataflash ? spi interface compatibility ? ide/atapi interface ? up to 32 bits of general-purpose i/os ? 1 interrupt keyboard ? smartmedia ? software interface ? 2 standard 16-bit timers/counters ? hardware watchdog timer ? standard full duplex uart with baud rate generator ? two wire master and slave modes controller ? spi master and slave modes controller ? power management ? power-on reset ? software programmable mcu clock ? idle mode, power-down mode ? operating conditions: ? 2.7 to 3.6v ? 37ma typical operating at 25c playing music on earphone ? temperature range: -40 c to +85 c ? power amplifier supply 3.2v to 5.5v ? packages ?ctbga100 single-chip flash microcontroller with mp3 decoder with full audio interface at83snd2c at89c51snd2c
2 at8xc51snd2c 4341e?mp3?06/05 description the at8xc51snd2c has been developed for handling mp3 ringing tones in mobile phones and can replace sound generators while adding sd/mmc card reader, mp3 music decoding, and connection of the cell phone to a pc through usb. cell phones can also be used as a thumb dr ive extending cell phone capabilities. the at8xc51snd2c are fully integrated stand -alone hardwired mpeg i/ii-layer 3 decoder with a c51 microcontroller core hand ling data flow, mp3-player control, stereo audio dac and mono audio power amplifier for speaker control. the at89c51snd2c includes 64k bytes of flash memory and allows in-system pro- gramming through an embedded 4k bytes of boot flash memory. the at83snd2c includes 64k bytes of rom memory. the at8xc51snd2c include 2304 bytes of ram memory. the at8xc51snd2c provides the necessary f eatures for human interface like timers, keyboard port, serial or parallel interface (usb, twi, spi, ide), i 2 s output, and all exter- nal memory interface (nand or nor flash, smartmedia, multimedia , dataflash cards). typical applications ? mp3-player ? pda, camera, mobile phone mp3 ? car audio/multimedia mp3 ? home audio/multimedia mp3
3 at8xc51snd2c 4341e?mp3?06/05 block diagram figure 1. at8xc51snd2c block diagram 8-bit internal bus clock and pll unit c51 (x2 core) flash rom interrupt handler unit filt x2 x1 mp3 twi controller mmc interface i/oports scl sda mdat p0-p4 vss vdd keyboard interface kin0 i 2 s/pcm audio int0 int1 mosi miso 3 alternate function of port 3 4 alternate function of port 4 timers 0/1 t1 t0 spi/dataflash controller mclk mcmd sck rst dsel dclk sclk dout 64 kbytes usb controller d+ d- uart rxd txd ide interface ss watchdog flash boot 4 kbytes isp uvss uvdd and brg ale 3 3 3 3 3 4 4 4 4 audio decoder interface pa audio dac unit hsr hsl auxp ram 2304bytes 3 auxn linel liner monop monon painp painn hpp hpn
4 at8xc51snd2c 4341e?mp3?06/05 pin description pinouts figure 2. at8xc51snd2c 100-pin bga package notes: 1. isp pin is only available in at89c51snd2c product. do not connect this pin on at83snd2c product. 2. nc is do not connect auxn 8 9765432 c b a d e f g h 1 ale nc audvdd hsvdd hsvss audvss audvcm nc hsl hsr pvss ingnd d+ p0.0/ nc pvdd linel x2 d- nc p0.3/ nc audvref filt liner x1 vss vss monon p0.4/ p0.5/ vss p3.0/ tst p3.6/ vdd p4.2/ p0.6/ p0.7/ vdd p3.1/ p3.4/ p3.5/ p3.7/ p4.1/ p4.0/ p4.3/ nc esdvss p3.2/ dsel dclk lphn p2.0/ p2.1/ p2.5/ mclk vdd nc sclk dout cbp nc p2.2/ p2.3/ p2.7/ vss mdat audrst vss audvss j p0.2/ p0.1/ nc auxp monop ad7 ss wr nc vdd p2.4/ p2.6/ ea mcmd rst nc vdd uvss uvdd vdd p3.3/ audvss hpn audvbat hpp painn painp mosi sck miso k a8 kin0 ad0 ad4 ad3 ad2 ad1 scl sda ad5 a9 a10 a11 a12 a13 a14 a15 t0 t1 txd rxd rd int1 int0 isp / 10 ad6 nc
5 at8xc51snd2c 4341e?mp3?06/05 signals all the at8xc51snd2c signals are detailed by functionality in table 1 to table 14. table 1. ports signal description table 2. clock signal description table 3. timer 0 and timer 1 signal description signal name type description alternate function p0.7:0 i/o port 0 p0 is an 8-bit open-drain bidirectiona l i/o port. port 0 pins that have 1s written to them float and can be used as high impedance inputs. to avoid any parasitic current consum ption, floating p0 inputs must be polarized to v dd or v ss . ad7:0 p2.7:0 i/o port 2 p2 is an 8-bit bidirectional i/o port with internal pull-ups. a15:8 p3.7:0 i/o port 3 p3 is an 8-bit bidirectional i/o port with internal pull-ups. rxd txd int0 int1 t0 t1 wr rd p4.3:0 i/o port 4 p4 is an 8-bit bidirectional i/o port with internal pull-ups. miso mosi sck ss signal name type description alternate function x1 i input to the on-chip inverting oscillator amplifier to use the internal oscillator, a crys tal/resonator circuit is connected to this pin. if an external oscillator is used, its output is connected to this pin. x1 is the clock s ource for internal timing. - x2 o output of the on-chip inverting oscillator amplifier to use the internal oscillator, a crys tal/resonator circuit is connected to this pin. if an external oscillat or is used, leave x2 unconnected. - filt i pll low pass filter input filt receives the rc network of the pll low pass filter. - signal name type description alternate function int0 i timer 0 gate input int0 serves as external run control for timer 0, when selected by gate0 bit in tcon register. external interrupt 0 int0 input sets ie0 in the tcon register. if bit it0 in this register is set, bit ie0 is set by a falling edge on int 0#. if bit it0 is cleared, bit ie0 is set by a low level on int0#. p3.2
6 at8xc51snd2c 4341e?mp3?06/05 table 4. audio interface signal description table 5. usb controller signal description table 6. mutimediacard interface signal description int1 i timer 1 gate input int1 serves as external run control for timer 1, when selected by gate1 bit in tcon register. external interrupt 1 int1 input sets ie1 in the tcon register. if bit it1 in this register is set, bit ie1 is set by a falling edge on int 1#. if bit it1 is cleared, bit ie1 is set by a low level on int1#. p3.3 t0 i timer 0 external clock input when timer 0 operates as a counter, a falling edge on the t0 pin increments the count. p3.4 t1 i timer 1 external clock input when timer 1 operates as a counter, a falling edge on the t1 pin increments the count. p3.5 signal name type description alternate function dclk o dac data bit clock - dout o dac audio data output - dsel o dac channel select signal dsel is the sample rate clock output. - sclk o dac system clock sclk is the oversampling clock sy nchronized to the digital audio data (dout) and the channel selection signal (dsel). - signal name type description alternate function d+ i/o usb positive data upstream port this pin requires an external 1.5 k : pull-up to v dd for full speed operation. - d- i/o usb negative data upstream port - signal name type description alternate function mclk o mmc clock output data or command clock transfer. - mcmd i/o mmc command line bidirectional command channel used for card initialization and data transfer commands. to avoid any pa rasitic current consumption, unused mcmd input must be polarized to v dd or v ss . - mdat i/o mmc data line bidirectional data channel. to avoid any parasitic current consumption, unused mdat input must be polarized to v dd or v ss . - signal name type description alternate function
7 at8xc51snd2c 4341e?mp3?06/05 table 7. uart signal description table 8. spi controller signal description table 9. twi controller signal description table 10. keypad interface signal description signal name type description alternate function rxd i/o receive serial data rxd sends and receives data in seri al i/o mode 0 and receives data in serial i/o modes 1, 2 and 3. p3.0 txd o transmit serial data txd outputs the shift clock in serial i/o mode 0 and transmits data in serial i/o modes 1, 2 and 3. p3.1 signal name type description alternate function miso i/o spi master input slave output data line when in master mode, miso receives data from the slave peripheral. when in slave mode, miso outputs data to the master controller. p4.0 mosi i/o spi master output slave input data line when in master mode, mosi outputs data to the slave peripheral. when in slave mode, mosi receives data from the master controller. p4.1 sck i/o spi clock line when in master mode, sck outputs cl ock to the slave peripheral. when in slave mode, sck receives clock from the master controller. p4.2 ss i spi slave select line when in controlled slave mode, ss enables the slave mode. p4.3 signal name type description alternate function scl i/o twi serial clock when twi controller is in master mode, scl outputs the serial clock to the slave peripherals. when twi cont roller is in slave mode, scl receives clock from t he master controller. - sda i/o twi serial data sda is the bidirectional two wire data line. - signal name type description alternate function kin0 i keypad input line holding this pin high or low for 24 oscillator periods triggers a keypad interrupt. -
8 at8xc51snd2c 4341e?mp3?06/05 table 11. external access signal description note: 1. for rom/flash/romless dice product versions only. table 12. system signal description table 13. power signal description signal name type description alternate function a15:8 i/o address lines upper address lines for the external bus. multiplexed higher address and data lines for the ide interface. p2.7:0 ad7:0 i/o address/data lines multiplexed lower address and data lines for the external memory or the ide interface. p0.7:0 ale o address latch enable output ale signals the start of an external bus cycle and indicates that valid address information is available on line s a7:0. an external latch is used to demultiplex the address from address/data bus. - isp i/o isp enable input (at89c51snd2c only) this signal must be held to gnd through a pull-down resistor at the falling reset to force execution of the internal bootloader. - rd o read signal read signal asserted during external data memory read operation. p3.7 wr o write signal write signal asserted during external data memory write operation. p3.6 ea (1) i external access enable: ea must be externally held low to enable the device to fetch code from external program memory locations 0000h to ffffh (rd). - signal name type description alternate function rst i reset input holding this pin high for 64 oscillator periods while the oscillator is running resets the device. the port pins are driven to their reset conditions when a voltage lower than v il is applied, whether or not the oscillator is running. this pin has an internal pull-down resi stor which allows the device to be reset by connecting a capacitor between this pin and v dd . asserting rst when the chip is in idle mode or power-down mode returns the chip to normal operation. - tst i test input test mode entry signal. this pin must be set to v dd . - signal name type description alternate function vdd pwr digital supply voltage connect these pins to +3v supply voltage. - vss gnd circuit ground connect these pins to ground. -
9 at8xc51snd2c 4341e?mp3?06/05 table 14. audio power signal description table 15. stereo audio dac and mono powe r amplifier signal description pvdd pwr pll supply voltage connect this pin to +3v supply voltage. - pvss gnd pll circuit ground connect this pin to ground. - uvdd pwr usb supply voltage connect this pin to +3v supply voltage. - uvss gnd usb ground connect this pin to ground. - signal name type description alternate function audvdd pwr audio digital supply voltage - audvss gnd audio circuit ground connect these pins to ground. - esdvss gnd audio analog circuit ground for electrostatic discharge . connect this pin to ground. - audvref pwr audio voltage reference pin for decoupling .- hsvdd pwr headset driver power supply .- hsvss gnd headset driver ground. connect this pin to ground. - audvbat pwr audio amplifier supply. - signal name type description alternate function lphn o low power audio stage output - hpn o negative speaker output - hpp o positivie speaker output - cbp o audio amplifier common mode voltage decoupling - painn i audio amplifier negative input - painp i audio amplifier positive input - audrst i audio reset (active low) - monon o audio negative monaural driver output - monop o audio positive monaural driver outpu t- auxp i audio mono auxiliary positive input - auxn i audio mono auxiliary negative input - hsl o audio left channel headset driver output - signal name type description alternate function
10 at8xc51snd2c 4341e?mp3?06/05 hsr o audio right channel headset driver output - linel i audio left channel line in - liner i audio right channel line in - ingnd i audio line signal ground pin for decoupling .- audvcm i audio common mode reference for decoupling - signal name type description alternate function
11 at8xc51snd2c 4341e?mp3?06/05 internal pin structure table 16. detailed internal pin structure notes: 1. for information on resistors value, inpu t/output levels, and drive capability, refer to the section ?dc characteristics?, page 201. 2. when the two wire controller is enabled, p 3 transistors are disabled allowing pseudo open-drain structure. circuit (1) type pins input tst input/output rst input/output p3 p4 input/output p0 mcmd mdat isp psen output ale sclk dclk dout dsel mclk input/output d+ d- r tst vdd r rst vss p vdd watchdog output p 3 vss n p 1 vdd vdd 2 osc latch output periods p 2 vdd vss n p vdd vss n p vdd d+ d-
12 at8xc51snd2c 4341e?mp3?06/05 clock controller the at8xc51snd2c clock cont roller is based on an on-chip oscillator feeding an on- chip phase lock loop (pll). all internal cl ocks to the peripherals and cpu core are generated by this controller. oscillator the at8xc51snd2c x1 and x2 pins are the input and the output of a single-stage on- chip inverter (see figure 3) that can be configured with off-chip components such as a pierce oscillator (see figure 4). value of capacitors and crystal characteristics are detailed in the section ?dc characteristics?. the oscillator outputs three different clocks: a clock for the pll, a clock for the cpu core, and a clock for the peripherals as sh own in figure 3. thes e clocks are either enabled or disabled, depending on the power reduction mode as detailed in the section ?power management? on page 46. the peripheral clock is used to generate the timer 0, timer 1, mmc, spi, and port sampling clocks. figure 3. oscillator block diagram and symbol figure 4. crystal connection x2 feature unlike standard c51 prod ucts that require 12 oscillator clock periods per machine cycle, the at8xc51snd2c need only 6 oscillator clock periods per machine cycle. this fea- ture called the ?x2 feature? can be enabled using the x2 bit (1) in ckcon (see table 17) and allows the at8xc51snd2c to operate in 6 or 12 oscillator clock periods per machine cycle. as shown in figure 3, both cpu and peripheral clocks are affected by this feature. figure 5 shows the x2 mode switching waveforms. after reset the standard mode is activated. in standard mode the cpu and peripheral clock frequency is the oscillator frequency divided by 2 while in x2 mode, it is the oscillator frequency. note: 1. the x2 bit reset value depends on the x2b bit in the hardware security byte (see table 23 on pa ge 22). using the at89 c51snd2c (flash version) the system can boot either in standard or x2 mode depending on the x2b value. using at83snd2c (rom version) the system always boots in standard mode. x2b bit can be changed to x2 mode later by software. x1 x2 pd pcon.1 idl pcon.0 peripheral cpu core 0 1 x2 ckcon.0 y 2 per clock clock clock peripheral clock symbol cpu clock cpu core clock symbol osc clock oscillator clock symbol oscillator clock vss x1 x2 q c1 c2
13 at8xc51snd2c 4341e?mp3?06/05 figure 5. mode switching waveforms note: 1. in order to prevent any incorrect operat ion while operating in x2 mode, user must be aware that all peripherals using clock frequen cy as time reference (timers, etc.) will have their time reference divided by 2. for example, a free running timer generating an interrupt every 20 ms will then generate an interrupt every 10 ms. pll pll description the at8xc51snd2c pll is used to generate internal high frequency clock (the pll clock) synchronized with an external low-frequency (the oscillator clock). the pll clock provides the mp3 decoder, the audio interface, and the usb interface clocks. figure 6 shows the internal structure of the pll. the pfld block is the phase frequency co mparator and lock detector. this block makes the comparison between the reference clock coming from the n divider and the reverse clock coming from the r divider and generates some pulses on the up or down signal depending on the edge position of the re verse clock. the pllen bit in pllcon register is used to enable the clock gener ation. when the pll is locked, the bit plock in pllcon register (see table 18) is set. the chp block is the charge pump that ge nerates the voltage reference for the vco by injecting or extracting charges from the ex ternal filter connec ted on pfilt pin (see figure 7). value of the filter components are detailed in the section ?dc characteristics?. the vco block is the voltage controlled oscillator controlled by the voltage v ref pro- duced by the charge pump. it generates a square wave signal: the pll clock. figure 6. pll block diagram and symbol x1 y 2 x1 clock x2 bi t x2 mode (1) std mode std mode pllen pllcon.1 n6:0 n divider r divider vco pllclk oscclk r 1 + u n1 + ---------------------------------------------- - = osc clock pfld plock pllcon.0 pfilt chp vref up down r9:0 pll clock pll clock symbol pll clock
14 at8xc51snd2c 4341e?mp3?06/05 figure 7. pll filter connection pll programming the pll is programmed using the flow shown in figure 8. as soon as clock generation is enabled, the user must wait until the lock indicator is set to ensure the clock output is stable. the pll clock frequency will depend on mp3 decoder clock and audio interface clock frequencies. figure 8. pll programming flow vss filt r c1 c2 vss pll programming configure dividers n6:0 = xxxxxxb r9:0 = xxxxxxxxxxb enable pll pllres = 0 pllen = 1 pll locked? plock = 1?
15 at8xc51snd2c 4341e?mp3?06/05 registers table 17. ckcon register ckcon (s:8fh) ? clock control register reset value = 0000 000xb (at89c51snd2c) or 0000 0000b (at83snd2c) table 18. pllcon register pllcon (s:e9h) ? pll control registe r 76543210 twix2 wdx2 - six2 - t1x2 t0x2 x2 bit number bit mnemonic description 7twix2 two-wire clock control bit set to select the oscillator clock divided by 2 as twi clock input (x2 independent). clear to select the peripheral cloc k as twi clock input (x2 dependent). 6wdx2 watchdog clock control bit set to select the oscillator clock divided by 2 as watchdog clock input (x2 independent). clear to select the peripheral cloc k as watchdog clock input (x2 dependent). 5- reserved the values read from this bit is indeterminate. do not set this bit. 4six2 enhanced uart clock (mode 0 and 2) control bit set to select the oscillator clock divided by 2 as uart clock input (x2 independent). clear to select the peripheral cloc k as uart clock input (x2 dependent).. 3- reserved the values read from this bit is indeterminate. do not set this bit. 2t1x2 timer 1 clock control bit set to select the oscill ator clock divided by 2 as timer 1 clock input (x2 independent). clear to select the peripheral cloc k as timer 1 clock input (x2 dependent). 1t0x2 timer 0 clock control bit set to select the oscill ator clock divided by 2 as timer 0 clock input (x2 independent). clear to select the peripheral cloc k as timer 0 clock input (x2 dependent). 0x2 system clock control bit clear to select 12 clock periods per machine cycle (std mode, f cpu = f per = f osc / 2). set to select 6 clock periods per machine cycle (x2 mode, f cpu = f per = f osc ). 76543210 r1 r0 - - pllres - pllen plock bit number bit mnemonic description 7 - 6 r1:0 pll least significant bits r divider 2 lsb of the 10-bit r divider. 5 - 4 - reserved the values read from these bits are always 0. do not set these bits.
16 at8xc51snd2c 4341e?mp3?06/05 reset value = 0000 1000b table 19. pllndiv register pllndiv (s:eeh) ? pll n divider register reset value = 0000 0000b table 20. pllrdiv register pllrdiv (s:efh) ? pll r divider register reset value = 0000 0000b 3 pllres pll reset bit set this bit to reset the pll. clear this bit to free the pll and allow enabling. 2- reserved the value read from this bit is always 0. do not set this bit. 1 pllen pll enable bit set to enable the pll. clear to disable the pll. 0plock pll lock indicator set by hardware when pll is locked. clear by hardware when pll is unlocked. 76543210 - n6n5n4n3n2n1n0 bit number bit mnemonic description 7- reserved the value read from this bit is always 0. do not set this bit. 6 - 0 n6:0 pll n divider 7 - bit n divider. 76543210 r9 r8 r7 r6 r5 r4 r3 r2 bit number bit mnemonic description 7 - 0 r9:2 pll most significant bits r divider 8 msb of the 10-bit r divider. bit number bit mnemonic description
17 at8xc51snd2c 4341e?mp3?06/05 program/code memory the at8xc51snd2c execute up to 64k bytes of program/code memory. figure 9 shows the split of internal and external pr ogram/code memory spaces depending on the product. the at83snd2c product provides the internal program/code memory in rom memory while the at89c51snd2c product provides it in flash memory. these 2 products do not allow external code memory execution. the flash memory increases eprom and rom fu nctionality by in-circuit electrical era- sure and programming. the high voltage needed for programming or erasing flash cells is generated on-chip using the standard v dd voltage, made possible by the internal charge pump. thus, the at89c51snd2c c an be programmed using only one voltage and allows in-application software programming. hardware programming mode is also available using common programming tools. see the application note ?programming t89c51x and at89c51x with device programmers?. the at89c51snd2c implements an additional 4k bytes of on-chip boot flash memory provided in flash memory. this boot memory is delivered programmed with a standard boot loader software allowing in-system programming (isp). it also contains some application programming interface routines named api routines allowing in application programming (iap) by using user?s own boot loader. figure 9. program/code memory organization rom memory architecture as shown in figure 10 the at83snd2c ro m memory is composed of one space detailed in the fo llowing paragraph. figure 10. at83snd2c memory architecture 4k bytes boot flash ffffh f000h 0000h 64k bytes code flash ffffh at89c51snd2c 0000h 64k bytes code rom ffffh at83snd2c f000h ffffh 64k bytes rom memory 0000h user
18 at8xc51snd2c 4341e?mp3?06/05 user space this space is composed of a 64k bytes rom memory programmed during the manu- facturing process. it contains the user?s application code. flash memory architecture as shown in figure 11 the at89c51snd2c flash memory is composed of four spaces detailed in the fo llowing paragraphs. figure 11. at89c51snd2c memory architecture user space this space is composed of a 64k bytes flash memory organized in 512 pages of 128 bytes. it contains the user?s application code. this space can be read or written by both software and hardware modes. boot space this space is composed of a 4k bytes flash memory. it contains the boot loader for in- system programming and the routines for in application programming. this space can only be read or written by hardware mode using a parallel programming tool. hardware security space this space is composed of one byte: the ha rdware security byte (hsb see table 23) divided in 2 separate nibbles. the msn cont ains the x2 mode configuration bit and the boot loader jump bit as detailed in section ?boot memory execution?, page 19 and can be written by software while the lsn contains the lock system leve l to protect the mem- ory content against piracy as detailed in section ?hardware security system?, page 19 and can only be written by hardware. extra row space this space is composed of 2 bytes: ? the software boot vector (sbv, see table 24). this byte is used by the software boot loader to build the boot address. ? the software security byte (ssb, see table 25). this byte is used to lock the execution of some boot loader commands. ffffh 64k bytes flash memory 0000h hardware security user 4k bytes flash memory ffffh f000h boot extra row
19 at8xc51snd2c 4341e?mp3?06/05 hardware security system the at89c51snd2c implements three lock bits lb2:0 in the lsn of hsb (see table 23) providing three levels of security for user?s program as described in table 21 while the at83snd2c is always set in read disabled mode. level 0 is the level of an erased part and does not enable any security feature. level 1 locks the hardware programming of both user and boot memories. level 2 locks also hardware verifying of both user and boot memories level 3 locks also the external execution. notes: 1. u means unprogrammed, p means programmed and x means don?t care (pro- grammed or unprogrammed). 2. at89c51snd2c products are delivered with third level programmed to ensure that the code programmed by software using i sp or user?s boot loader is secured from any hardware piracy. boot memory execution as internal c51 code space is limited to 64k bytes, some mechanisms are implemented to allow boot memory to be mapped in the code space for execution at addresses from f000h to ffffh. the boot memory is enabled by setting the enboot bit in auxr1 (see figure 22). the three ways to set this bit are detailed in the following sections. software boot mapping the software way to set enboot consists in writing to auxr1 from the user?s soft- ware. this enables boot loader or api routines execution. hardware condition boot mapping the hardware condition is based on the isp pin. when driving this pin to low level, the chip reset sets enboot and forces the reset vector to f000h instead of 0000h in order to execute the boot loader software. as shown in figure 12 the hardware condit ion always allows in-system recovery when user?s memory has been corrupted. programmed condition boot mapping the programmed condition is based on the boot loader jump bit (bljb) in hsb. as shown in figure 12 when this bit is progra mmed (by hardware or software programming mode), the chip reset set enboot and forces the reset vector to f000h instead of 0000h, in order to execute the boot loader software. table 21. lock bit features (1) level lb2 lb1 lb0 internal execution external execution hardware verifying hardware programming software programming 0 u u u enable enable enable enable enable 1 u u p enable enable enable disable enable 2 u p x enable enable disable disable enable 3 (3) p x x enable disable disable disable enable
20 at8xc51snd2c 4341e?mp3?06/05 figure 12. hardware boot pr ocess algorithm the software process (boot loader) is detailed in the ?boot loader datasheet? document. preventing flash corruption see section ?reset recommendation to prevent flash corruption?, page 47. atmel?s boot loader hardware software hard cond? isp = l? reset hard cond init enboot = 1 pc = f000h fcon = 00h prog cond? bljb = p? standard init enboot = 0 pc = 0000h fcon = f0h prog cond init enboot = 1 pc = f000h fcon = f0h user?s application process process
21 at8xc51snd2c 4341e?mp3?06/05 registers table 22. auxr1 register auxr1 (s:a2h) ? auxiliary register 1 reset value = xxxx 00x0b note: 1. enboot bit is only available in at89c51snd2c product. 76543210 - - enboot - gf3 0 - dps bit number bit mnemonic description 7 - 6 - reserved the value read from these bits are indeterminate. do not set these bits. 5 enboot 1 enable boot flash set this bit to map the boot flash in the code space between at addresses f000h to ffffh. clear this bit to disable boot flash. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3gf3 general flag this bit is a general-purpose user flag. 20 always zero this bit is stuck to logic 0 to allow in c auxr1 instruction without affecting gf3 flag. 1- reserved for data pointer extension. 0dps data pointer select bit set to select second data pointer: dptr1. clear to select first data pointer: dptr0.
22 at8xc51snd2c 4341e?mp3?06/05 hardware bytes table 23. hsb byte ? hardwa re security byte reset value = xxuu uxxx, uuuu uuuu afte r an hardware full chip erase. note: 1. x2b initializes the x2 bit in ckcon during the reset phase. 2. in order to ensure boot loader activation at first power-up, at89c51snd2c products are delivered with bljb programmed. 3. bits 0 to 3 (lsn) can only be programmed by hardware mode. reset value = xxxx xxxx, uu uu uuuu after an hard ware full chip erase. reset value = xxxx xxxx, uu uu uuuu after an hard ware full chip erase. 76543210 x2b bljb - - - lb2 lb1 lb0 bit number bit mnemonic description 7x2b (1) x2 bit program this bit to start in x2 mode. unprogram (erase) this bit to start in standard mode. 6bljb (2) boot loader jump bit program this bit to execute the boot loader at address f000h on next reset. unprogram (erase) this bit to execut e user?s application at address 0000h on next reset. 5 - 4 - reserved the value read from these bits is alwa ys unprogrammed. do not program these bits. 3- reserved the value read from this bit is always unprogrammed. do not program this bit. 2 - 0 lb2:0 hardware lock bits refer to for bits description. table 24. sbv byte ? software boot vector 76543210 add15 add14 add13 add12 add11 add10 add9 add8 bit number bit mnemonic description 7 - 0 add15:8 msb of the user?s boot loader 16-bit address location refer to the boot loader datasheet for usage information (boot loader dependent) table 25. ssb byte ? software security byte 76543210 ssb7 ssb6 ssb5 ssb4 ssb3 ssb2 ssb1 ssb0 bit number bit mnemonic description 7 - 0 ssb7:0 software security byte data refer to the boot loader datasheet for usage information (boot loader dependent)
23 at8xc51snd2c 4341e?mp3?06/05 data memory the at8xc51snd2c provides data memory access in 2 different spaces: 1. the internal space mapped in three separate segments: ? the lower 128 bytes ram segment ? the upper 128 bytes ram segment ? the expanded 2048 bytes ram segment 2. the external space. a fourth internal segment is available but dedicated to special function registers, sfrs, (addresses 80h to ffh) accessible by direct addressing mode. for information on this segment, refer to the section ?special function registers?, page 30. figure 13 shows the internal and external data memory spaces organization. figure 13. internal and external data memory organization internal space lower 128 bytes ram the lower 128 bytes of ram (see figure 14) are accessible from address 00h to 7fh using direct or indirect addressing modes. the lowest 32 bytes are grouped into 4 banks of 8 registers (r0 to r7). 2 bits rs0 and rs1 in psw register (see table 29) select which bank is in use according to tabl e 26. this allows more efficient use of code space, since register instructions are shorte r than instructions t hat use direct address- ing, and can be used for context swit ching in interrupt service routines. table 26. register bank selection the next 16 bytes above the register banks form a block of bit-addressable memory space. the c51 instruction set includes a wide selection of single-bit instructions, and the 128 bits in this area can be directly addressed by these instructions. the bit addresses in this area are 00h to 7fh. 2k bytes upper 128 bytes internal ram lower 128 bytes internal ram special function registers 80h 80h 00h 7ffh ffh 00h ffh 64k bytes external xram 0000h ffffh direct addressing addressing 0800h 7fh internal eram direct or indirect indirect addressing extram = 0 extram = 1 rs1 rs0 description 0 0 register bank 0 from 00h to 07h 0 1 register bank 1 from 08h to 0fh 1 0 register bank 2 from 10h to 17h 1 1 register bank 3 from 18h to 1fh
24 at8xc51snd2c 4341e?mp3?06/05 figure 14. lower 128 bytes internal ram organization upper 128 bytes ram the upper 128 bytes of ram are accessible from address 80h to ffh using only indirect addressing mode. expanded ram the on-chip 2k bytes of expanded ram (eram) are accessible from address 0000h to 07ffh using indirect addressing mode through movx instructions. in this address range, extram bit in auxr register (see table 30) is used to select the eram (default) or the xram. as shown in figure 13 when extram = 0, the eram is selected and when extram = 1, the xram is selected (see section ?external space?). the eram memory can be resized using xrs1:0 bits in auxr register to dynamically increase external access to the xram spac e. table 27 details the selected eram size and address range. table 27. eram size selection note: lower 128 bytes ram, upper 128 byte s ram, and expanded ram are made of volatile memory cells. this means that the ram co ntent is indeterminate after power-up and must then be initialized properly. bit-addressable space 4 banks of 8 registers r0-r7 30h 7fh (bit addresses 0-7fh) 20h 2fh 18h 1fh 10h 17h 08h 0fh 00h 07h xrs1 xrs0 eram size address 0 0 256 bytes 0 to 00ffh 0 1 512 bytes 0 to 01ffh 1 0 1k byte 0 to 03ffh 1 1 2k bytes 0 to 07ffh
25 at8xc51snd2c 4341e?mp3?06/05 external space memory interface the external memory interface comprises the external bus (port 0 and port 2) as well as the bus control signals (rd , wr , and ale). figure 15 shows the structure of the external address bus. p0 carries address a7:0 while p2 carries addre ss a15:8. data d7:0 is multiple xed with a7:0 on p0. table 28 describes the external me mory interface signals. figure 15. external data memory interface structure table 28. external data memory interface signals page access mode the at8xc51snd2c implement a feature ca lled page access that disables the output of dph on p2 when executi ng movx @dptr inst ruction. page access is enable by setting the dphdis bit in auxr register. page access is useful when application uses both eram and 256 bytes of xram. in this case, software modifies intensively ext ram bit to select access to eram or xram and must save it if used in interrupt service routine. page access allows external access above 00ffh address without generating dph on p2. thus eram is accessed using movx @ri or movx @dptr with dptr < 0100h, < 0200h, < 0400h or < 0800h depending on the xrs1:0 bits value. then xram is accessed using movx @dptr with dptr t 0800h regardless of xrs1:0 bits value while keeping p2 for general i/o usage. signal name type description alternate function a15:8 o address lines upper address lines for the external bus. p2.7:0 ad7:0 i/o address/data lines multiplexed lower address lines and data for the external memory. p0.7:0 ale o address latch enable ale signals indicates that valid addre ss information are available on lines ad7:0. - rd o read read signal output to external data memory. p3.7 wr o write write signal output to external memory. p3.6 ram peripheral at8xc51snd2c p2 p0 ad7:0 a15:8 a7:0 a15:8 d7:0 a7:0 ale wr oe rd wr latch
26 at8xc51snd2c 4341e?mp3?06/05 external bus cycles this section describes the bus cycles the at8xc51snd2c executes to read (see figure 16), and write data (see figure 17) in the external data memory. external memory cycle takes 6 cpu clock per iods. this is equival ent to 12 oscillator clock period in standard mode or 6 oscillator clock periods in x2 mode. for further infor- mation on x2 mode, refer to the section ?x2 feature?, page 12. slow peripherals can be acce ssed by stretching the read and write cycles. this is done using the m0 bit in auxr register. sett ing this bit changes the width of the rd and wr signals from 3 to 15 cpu clock periods. for simplicity, figure 16 and fi gure 17 depict the bus cycle waveforms in idealized form and do not provide precise timing information. for bus cycle timing parameters refer to the section ?ac characteristics?. figure 16. external data read waveforms notes: 1. rd signal may be stretched using m0 bit in auxr register. 2. when executing movx @ri instruct ion, p2 outputs sfr content. 3. when executing movx @dptr instruction, if dphdis is set (page access mode), p2 outputs sfr content instead of dph. figure 17. external data write waveforms notes: 1. wr signal may be stretched using m0 bit in auxr register. 2. when executing movx @ri instruct ion, p2 outputs sfr content. 3. when executing movx @dptr instruction, if dphdis is set (page access mode), p2 outputs sfr content instead of dph. ale p0 p2 rd (1) dpl or ri d7:0 dph or p2 (2),(3) p2 cpu clock ale p0 p2 wr (1) dpl or ri d7:0 p2 cpu clock dph or p2 (2),(3)
27 at8xc51snd2c 4341e?mp3?06/05 dual data pointer description the at8xc51snd2c implement a second data pointer for speeding up code execution and reducing code size in case of intens ive usage of external memory accesses. dptr0 and dptr1 are seen by the cpu as dptr and are accessed using the sfr addresses 83h and 84h that are the dph and dpl addresses. the dps bit in auxr1 register (see table 22) is used to select whether dptr is the data pointer 0 or the data pointer 1 (see figure 18). figure 18. dual data pointer implementation application software can take advantage of the additional data pointers to both increase speed and reduce code size, for example, block operati ons (copy, compare, search ?) are well served by using one data pointer as a ?sourc e? pointer and the other one as a ?destina- tion? pointer. below is an example of block move impl ementation using the 2 pointers and coded in assembler. the latest c compiler also ta kes advantage of this f eature by providing enhanced algorithm libraries. the inc instruction is a short (2 bytes) and fast (6 cpu clocks) way to manipulate the dps bit in the auxr1 register. however, note that the inc instruction does not directly force the dps bit to a particular state, but si mply toggles it. in simple routines, such as the block move example, only the fact that dps is toggled in the proper sequence mat- ters, not its actual value. in other words, the block move routine works the same whether dps is '0' or '1' on entry. ; ascii block move using dual data pointers ; modifies dptr0, dptr1, a and psw ; ends when encountering null character ; note: dps exits opposite of entry state unless an extra inc auxr1 is added auxr1 equ 0a2h move: mov dptr,#source ; address of source inc auxr1 ; switch data pointers mov dptr,#dest ; address of dest mv_loop: inc auxr1 ; switch data pointers movx a,@dptr ; get a byte from source inc dptr ; increment source address inc auxr1 ; switch data pointers movx @dptr,a ; write the byte to dest inc dptr ; increment dest address jnz mv_loop ; check for null terminator end_move: 0 1 dph0 dph1 dpl0 0 1 dps auxr1.0 dph dpl dpl1 dptr dptr0 dptr1
28 at8xc51snd2c 4341e?mp3?06/05 registers table 29. psw register psw (s:8eh) ? program status word register reset value = 0000 0000b 76543210 cy ac f0 rs1 rs0 ov f1 p bit number bit mnemonic description 7cy carry flag carry out from bit 1 of alu operands. 6ac auxiliary carry flag carry out from bit 1 of addition operands. 5f0 user definable flag 0 4 - 3 rs1:0 register bank select bits refer to table 26 for bits description. 2ov overflow flag overflow set by arithmetic operations. 1f1 user definable flag 1 0p parity bit set when acc contains an odd number of 1?s. cleared when acc contains an even number of 1?s.
29 at8xc51snd2c 4341e?mp3?06/05 table 30. auxr register auxr (s:8eh) ? auxiliary control register reset value = x000 1101b 76543210 - ext16 m0 dphdis xrs1 xrs0 extram ao bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6 ext16 external 16-bit access enable bit set to enable 16-bit access mode during movx instructions. clear to disable 16-bit access mode and enable standard 8-bit access mode during movx instructions. 5m0 external memory access stretch bit set to stretch rd or wr signals duration to 15 cpu clock periods. clear not to stretch rd or wr signals and set duration to 3 cpu clock periods. 4dphdis dph disable bit set to disable dph output on p2 when executing movx @dptr instruction. clear to enable dph output on p2 when executing movx @dptr instruction. 3 - 2 xrs1:0 expanded ram size bits refer to table 27 for eram size description. 1 extram external ram enable bit set to select the external xram w hen executing movx @ri or movx @dptr instructions. clear to select the internal expanded ram when executing movx @ri or movx @dptr instructions. 0ao ale output enable bit set to output the ale signal only during movx instructions. clear to output the ale signal at a constant rate of f cpu /3.
30 at8xc51snd2c 4341e?mp3?06/05 special function registers the special function registers (sfrs) of the at8xc51snd2c derivatives fall into the categories detailed in table 31 to table 19. the relative addresses of these sfrs are provided together with their reset values in table 48. in this table, the bit-addressable registers are identified by note 1. note: 1. enboot bit is only available in at89c51snd2c product. table 31. c51 core sfrs mnemonicaddname 76543210 acc e0h accumulator b f0h b register psw d0h program status word cy ac f0 rs1 rs0 ov f1 p sp 81h stack pointer dpl 82h data pointer low byte dph 83h data pointer high byte table 32. system management sfrs mnemonicaddname 76543210 pcon 87h power control smod1 smod0 - - gf1 gf0 pd idl auxr 8eh auxiliary register 0 - ext16 m0 dphdis xrs1 xrs0 extram ao auxr1 a2h auxiliary register 1 - - enboot (1) -gf30 -dps nvers fbh version number nv7 nv6 nv5 nv4 nv3 nv2 nv1 nv0 table 33. pll and system clock sfrs mnemonicaddname 76543210 ckcon8fhclock control -------x2 pllcon e9h pll control r1 r0 - - pllres - pllen plock pllndiv eeh pll n divider - n6 n5 n4 n3 n2 n1 n0 pllrdivefhpll r divider r9r8r7r6r5r4r3r2 table 34. interrupt sfrs mnemonicaddname 76543210 ien0 a8h interrupt enable control 0 ea eaud emp3 es et1 ex1 et0 ex0 ien1 b1h interrupt enable control 1 - eusb - ekb - espi ei2c emmc iph0 b7h interrupt priority control high 0 - iphaud iphmp3 iphs ipht1 iphx1 ipht0 iphx0 ipl0 b8h interrupt priority control low 0 - iplaud iplmp3 ipls iplt1 iplx1 iplt0 iplx0 iph1 b3h interrupt priority control high 1 - iphusb - iphkb - iphspi iphi2c iphmmc ipl1 b2h interrupt priority control low 1 - iplusb - iplkb - iplspi ipli2c iplmmc
31 at8xc51snd2c 4341e?mp3?06/05 note: 1. fcon register is only available in at89c51snd2c product. table 35. port sfrs mnemonicaddname 76543210 p0 80h 8-bit port 0 p2 a0h 8-bit port 2 p3 b0h 8-bit port 3 p4c0h4-bit port 4 ---- table 36. auxiliary sfrs mnemonicaddname 76 5 4 3210 auxcon 90h auxiliary control sda scl - audcdout audcdin audcclk audccs kin0 table 37. flash memory sfr mnemonicaddname 76543210 fcon (1) d1h flash control fpl3 fpl2 fpl1 fpl0 fps fmod1 fmod0 fbusy table 38. timer sfrs mnemonicaddname 76543210 tcon 88h timer/counter 0 and 1 control tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 tmod 89h timer/counter 0 and 1 modes gate1 c/t1# m11 m01 gate0 c/t0# m10 m00 tl0 8ah timer/counter 0 low byte th0 8ch timer/counter 0 high byte tl1 8bh timer/counter 1 low byte th1 8dh timer/counter 1 high byte wdtrst a6h watchdog timer reset wdtprg a7h watchdog timer program -----wto2wto1wto0
32 at8xc51snd2c 4341e?mp3?06/05 table 39. mp3 decoder sfrs mnemonicaddname 76543210 mp3con aah mp3 control mpen mpbbst crcen mskanc mskreq msklay msksyn mskcrc mp3sta c8h mp3 status mpanc mpreq er rlay errsyn errcrc mpfs1 mpfs0 mpver mp3sta1 afh mp3 status 1 - - - mpfreq mpbreq - - - mp3dat ach mp3 data mpd7 mpd6 mpd5 mpd4 mpd3 mpd2 mpd1 mpd0 mp3anc adh mp3 ancillary data an d7 and6 and5 and4 and3 and2 and1 and0 mp3vol 9eh mp3 audio volume control left - - - vol4 vol3 vol2 vol1 vol0 mp3vor 9fh mp3 audio volume control right - - - vor4 vor3 vor2 vor1 vor0 mp3bas b4h mp3 audio bass control - - - bas4 bas3 bas2 bas1 bas0 mp3med b5h mp3 audio medium control - - - med4 med3 med2 med1 med0 mp3tre b6h mp3 audio treble control - - - tre4 tre3 tre2 tre1 tre0 mp3clk ebh mp3 clock divider - - - mpcd4 mpcd3 mpcd2 mpcd1 mpcd0 table 40. audio interface sfrs mnemonicaddname 76543210 audcon0 9ah audio control 0 just4 just3 just2 just1 just0 pol dsiz hlr audcon1 9bh audio control 1 src drqen msreq mudrn - dup1 dup0 auden audsta 9ch audio status sreq udrn aubusy - ---- auddat 9dh audio data aud7 aud6 aud5 aud4 aud3 aud2 aud1 aud0 audclk ech audio clock divider - - - aucd4 aucd3 aucd2 aucd1 aucd0
33 at8xc51snd2c 4341e?mp3?06/05 table 41. usb controller sfrs mnemonicaddname 76543210 usbcon bch usb global control usbe suspclk sdrmwup - uprsm rmwupe confg fadden usbaddr c6h usb address fen uadd6 uadd5 uadd4 uadd3 uadd2 uadd1 uadd0 usbint bdh usb global interrupt - - wupcpu eorint sofint - - spint usbien beh usb global interrupt enab le - - ewupcpu eeorint esofint - - espint uepnumc7husb endpoint number ------epnum1epnum0 uepconx d4h usb endpoint x control epen n akien nakout nakin dtgl epdir eptype1 eptype0 uepstax ceh usb endpoint x status dir rxoutb1 stallrq txrdy stlcrc rxsetup rxoutb0 txcmp ueprstd5husb endpoint reset -----ep2rstep1rstep0rst uepintf8husb endpoint interrupt -----ep2intep1intep0int uepienc2husb endpoint interrupt enable-----ep2inteep1inteep0inte uepdatx cfh usb endpoint x fifo data fdat7 fdat6 fdat5 fdat4 fdat3 fdat2 fdat1 fdat0 ubyctx e2h usb endpoint x byte counter - byct6 byct5 byct4 byct3 byct2 byct1 byct0 ufnuml bah usb frame number low fnum7 fnum6 fnum5 fnum4 fnum3 fnum2 fnum1 fnum0 ufnumh bbh usb frame number high - - crcok crcerr - fnum10 fnum9 fnum8 usbclkeahusb clock divider ------usbcd1usbcd0 table 42. mmc controller sfrs mnemonicaddname 76543210 mmcon0 e4h mmc control 0 drptr dtptr crptr ctptr mblock dfmt rfmt crcdis mmcon1 e5h mmc control 1 blen3 blen2 blen1 blen0 datdir daten respen cmden mmcon2 e6h mmc control 2 mmcen dcr ccr - - datd1 datd0 flowc mmsta deh mmc control and status - - cbusy crc16s datfs crc7s respfs cflck mmint e7h mmc interrupt mcbi eori eoci eofi f2fi f1fi f2ei f1ei mmmsk dfh mmc interrupt mask mcbm eorm eocm eofm f2fm f1fm f2em f1em mmcmd ddh mmc command mc7 mc6 mc5 mc4 mc3 mc2 mc1 mc0 mmdat dch mmc data md7 md6 md5 md4 md3 md2 md1 md0 mmclk edh mmc clock divider mmcd7 mmcd6 mmcd5 mmcd4 mmcd3 mmcd2 mmcd1 mmcd0 table 43. ide interface sfr mnemonicaddname 76543210 dat16h f9h high order data byte d15 d14 d13 d12 d11 d10 d9 d8
34 at8xc51snd2c 4341e?mp3?06/05 table 44. serial i/o port sfrs mnemonicaddname 76543210 scon 98h serial control fe/sm0 sm1 sm2 ren tb8 rb8 ti ri sbuf 99h serial data buffer saden b9h slave address mask saddr a9h slave address bdrcon 92h baud rate control brr tbck rbck spd src brl 91h baud rate reload table 45. spi controller sfrs mnemonicaddname 76543210 spcon c3h spi control spr2 spen ssdis mstr cpol cpha spr1 spr0 spsta c4h spi status spif wcol - modf ---- spdat c5h spi data spd7 spd6 spd5 spd4 spd3 spd2 spd1 spd0 table 46. two wire controller sfrs mnemonicaddname 76543210 sscon 93h synchronous serial control sscr2 sspe sssta sssto ssi ssaa sscr1 sscr0 sssta 94h synchronous serial status ssc4 ssc3 ssc2 ssc1 ssc0 0 0 0 ssdat 95h synchronous serial data ssd 7 ssd6 ssd5 ssd4 ssd3 ssd2 ssd1 ssd0 ssadr 96h synchronous serial address ssa7 ssa6 ssa5 ssa4 ssa3 ssa2 ssa1 ssgc table 47. keyboard interface sfrs mnemonicaddname 76543210 kbcon a3h keyboard control - - - kinl0 - - - kinm0 kbsta a4h keyboard status kpde - - - - - - kinf0
35 at8xc51snd2c 4341e?mp3?06/05 reserved notes: 1. sfr registers with least significant nibble address equal to 0 or 8 are bit-addressable. 2. nvers reset value depends on the silicon version: 1000 0100 for at89c51snd2c product and 0000 0001 for at83snd2c product. 3. fcon register is only available in at89c51snd2c product. 4. fcon reset value is 00h in case of reset with hardware condition. 5. ckcon reset value depends on the x2b bit (programmed or unprogrammed) in the hardware byte. table 48. sfr addresses and reset values 0/8 1/9 2/a 3/b 4/c 5/d 6/e 7/f f8h uepint 0000 0000 dat16h xxxx xxxx nvers xxxx xxxx (2) ffh f0h b (1) 0000 0000 f7h e8h pllcon 0000 1000 usbclk 0000 0000 mp3clk 0000 0000 audclk 0000 0000 mmclk 0000 0000 pllndiv 0000 0000 pllrdiv 0000 0000 efh e0h acc (1) 0000 0000 ubyctlx 0000 0000 mmcon0 0000 0000 mmcon1 0000 0000 mmcon2 0000 0000 mmint 0000 0011 e7h d8h p5 (1) xxxx 1111 mmdat 1111 1111 mmcmd 1111 1111 mmsta 0000 0000 mmmsk 1111 1111 dfh d0h psw (1) 0000 0000 fcon (3) 1111 0000 (4) uepconx 1000 0000 ueprst 0000 0000 d7h c8h mp3sta (1) 0000 0001 uepstax 0000 0000 uepdatx xxxx xxxx cfh c0h p4 (1) 1111 1111 uepien 0000 0000 spcon 0001 0100 spsta 0000 0000 spdat xxxx xxxx usbaddr 0000 0000 uepnum 0000 0000 c7h b8h ipl0 (1) x000 0000 saden 0000 0000 ufnuml 0000 0000 ufnumh 0000 0000 usbcon 0000 0000 usbint 0000 0000 usbien 0001 0000 bfh b0h p3 (1) 1111 1111 ien1 0000 0000 ipl1 0000 0000 iph1 0000 0000 mp3bas 0000 0000 mp3med 0000 0000 mp3tre 0000 0000 iph0 x000 0000 b7h a8h ien0 (1) 0000 0000 saddr 0000 0000 mp3con 0011 1111 mp3dat 0000 0000 mp3anc 0000 0000 mp3sta1 0100 0001 afh a0h p2 (1) 1111 1111 auxr1 xxxx 00x0 kbcon 0000 1111 kbsta 0000 0000 wdtrst xxx xxxx wdtprg xxxx x000 a7h 98h scon 0000 0000 sbuf xxxx xxxx audcon0 0000 1000 audcon1 1011 0010 audsta 1100 0000 auddat 1111 1111 mp3vol 0000 0000 mp3vor 0000 0000 9fh 90h auxcon (1) 1111 1111 brl 0000 0000 bdrcon xxx0 0000 sscon 0000 0000 sssta 1111 1000 ssdat 1111 1111 ssadr 1111 1110 97h 88h tcon (1) 0000 0000 tmod 0000 0000 tl0 0000 0000 tl1 0000 0000 th0 0000 0000 th1 0000 0000 auxr x000 1101 ckcon 0000 000x (5) 8fh 80h p0 (1) 1111 1111 sp 0000 0111 dpl 0000 0000 dph 0000 0000 pcon 00xx 0000 87h 0/8 1/9 2/a 3/b 4/c 5/d 6/e 7/f
36 at8xc51snd2c 4341e?mp3?06/05 interrupt system the at8xc51snd2c, like other control-orient ed computer architectures, employ a pro- gram interrupt method. this operation br anches to a subroutine and performs some service in response to the interrupt. when the subroutine completes, execution resumes at the point where the interrupt occurred. interrupts may occur as a result of internal at8xc51snd2c activity (e.g., timer overflow) or at the initiation of electrical signals external to the microcontroller (e.g., keyb oard). in all cases, interrupt operation is pro- grammed by the system designer, who determine s priority of interrupt service relative to normal code execution and other interrupt service routines. all of the interrupt sources are enabled or disabled by the system designer and may be manipulated dynamically. a typical interrupt event chain occurs as follows: ? an internal or external device initiates an interrupt-request signal. the at8xc51snd2c, latches this event into a flag buffer. ? the priority of the flag is compared to the priority of other interr upts by the interrupt handler. a high priority causes th e handler to set an interrupt flag. ? this signals the instruction execution unit to execute a context switch. this context switch breaks the current flow of instruction sequences. the execution unit completes the current instruction prior to a save of the program counter (pc) and reloads the pc with the start address of a software service routine. ? the software service routine executes assigned tasks and as a final activity performs a reti (return from interrupt) instruction. this instruction signals completion of the interrupt, resets the interrupt-in-progress priority and reloads the program counter. program operation then continues from the original point of interruption. table 49. interrupt system signals six interrupt registers are used to control th e interrupt system. 2 8-bit registers are used to enable separately the interrupt sources: ien0 and ien1 registers (see table 52 and table 53). four 8-bit registers are used to establish the priority level of the different sources: iph0, ipl0, iph1 and ipl1 registers (see table 54 to table 57). interrupt system priorities each of the interrupt sources on the at8xc51snd2c can be individually programmed to one of four priority levels . this is accomplished by one bi t in the interrupt priority high registers (iph0 and iph1) and one bit in the in terrupt priority low registers (ipl0 and ipl1). this provides each interrupt source four possible priority levels according to table 50. signal name type description alternate function int0 i external interrupt 0 see section "external interrupts", page 39. p3.2 int1 i external interrupt 1 see section ?external interrupts?, page 39. p3.3 kin0 i keyboard interrupt input see section ?keyboard interface?, page 198. -
37 at8xc51snd2c 4341e?mp3?06/05 table 50. priority levels a low-priority interrupt is always interrupted by a higher priority interrupt but not by another interrupt of lower or equal priority. higher priority interrupts are serviced before lower priority interrupts. the response to simultaneous occurrence of equal priority inter- rupts is determined by an internal hard ware polling sequence detailed in table 51. thus, within each priority level there is a second priority structure determined by the polling sequence. the interrupt cont rol system is shown in figure 19. table 51. priority within same level iphxx iplxx priority level 0 0 0 lowest 011 102 1 1 3 highest interrupt name priority number interrupt address vectors interrupt request flag cleared by hardware (h) or by software (s) int0 0 (highest priority) c:0003h int0 timer 0 1 c:000bh timer 0 int1 2 c:0013h int1 timer 1 3 c:001bh timer 1 serial port 4 c:0023h serial port mp3 decoder 5 c:002bh mp3 decoder audio interface 6 c:0033h audio interface mmc interface 7 c:003bh mmc interface two wire controller 8 c:0043h two wire controller spi controller 9 c:004bh spi controller reserved 10 c:0053h reserved keyboard 11 c:005bh keyboard reserved 12 c:0063h reserved usb 13 c:006bh usb reserved 14 (lowest priority) c:0073h reserved
38 at8xc51snd2c 4341e?mp3?06/05 figure 19. interrupt control system ei2c ien1.1 emmc ien1.0 eusb ien1.6 espi ien1.2 ex0 ien0.0 00 01 10 11 external interrupt 0 int0 ea ien0.7 ex1 ien0.2 external interrupt 1 int1 et0 ien0.1 timer 0 emp3 ien0.5 mp3 decoder et1 ien0.3 timer 1 eaud ien0.6 audio interface spi controller usb controller ekb ien1.4 keyboard mmc controller twi controller iph/l interrupt enable lowest priority interrupts highest kin0 priority enable sck si so scl sda 00 01 10 11 00 01 10 11 00 01 10 11 00 01 10 11 00 01 10 11 00 01 10 11 00 01 10 11 00 01 10 11 00 01 10 11 00 01 10 11 priority interrupts es ien0.4 serial port 00 01 10 11 txd rxd mclk mdat mcmd d+ d-
39 at8xc51snd2c 4341e?mp3?06/05 external interrupts int1:0 inputs external interrupts int0 and int1 (intn , n = 0 or 1) pins may each be programmed to be level-triggered or edge-triggered, dependent upon bits it0 and it1 (itn, n = 0 or 1) in tcon register as shown in figure 20. if itn = 0, intn is triggered by a low level at the pin. if itn = 1, intn is negative-edge triggered. external interrupts are enabled with bits ex0 and ex1 (exn, n = 0 or 1) in ien0. events on intn set the interrupt request flag ien in tcon register. if the interrupt is edge-triggered, the request flag is cleared by hard- ware when vectoring to the inte rrupt service routine. if the in terrupt is level- triggered, the interrupt service routine must clear t he request flag and the interrupt must be deas- serted before the end of the interrupt service routine. int0 and int1 inputs provide both the capability to exit from power-down mode on low level signals as detailed in sectio n ?exiting power-down mode?, page 48. figure 20. int1:0 input circuitry kin0 inputs external interrupts kin0 provides the c apability to connect a keyboard. for detailed information on this inputs, refer to section ?keyboard interface?, page 198. input sampling external interrupt pins (int1:0 and kin0) are sampled on ce per peripheral cycle (6 peripheral clock periods) (see figure 21). a level-triggered interrupt pin held low or high for more than 6 perip heral clock periods (12 oscillator in standard mode or 6 oscillator clock periods in x2 mode) guarantees detection. edge-triggered external interrupts must hold the request pin low for at least 6 peripheral clock periods. figure 21. minimum pulse timings 0 1 int0/1 it0/1 tcon.0/2 ex0/1 ien0.0/2 int0/1 interrupt request ie0/1 tcon.1/3 edge-triggered interrupt level-triggered interrupt 1 cycle 1 cycle > 1 peripheral cycle 1 cycle > 1 peripheral cycle
40 at8xc51snd2c 4341e?mp3?06/05 registers table 52. ien0 register ien0 (s:a8h) ? interrupt enable register 0 reset value = 0000 0000b 76543210 ea eaud emp3 es et1 ex1 et0 ex0 bit number bit mnemonic description 7ea enable all interrupt bit set to enable all interrupts. clear to disable all interrupts. if ea = 1, each interrupt source is indivi dually enabled or disabled by setting or clearing its interrupt enable bit. 6 eaud audio interface interrupt enable bit set to enable audio interface interrupt. clear to disable audio interface interrupt. 5emp3 mp3 decoder interrupt enable bit set to enable mp3 decoder interrupt. clear to disable mp3 decoder interrupt. 4es serial port interrupt enable bit set to enable serial port interrupt. clear to disable serial port interrupt. 3et1 timer 1 overflow interrupt enable bit set to enable timer 1 overflow interrupt. clear to disable timer 1 overflow interrupt. 2ex1 external interrupt 1 enable bit set to enable external interrupt 1. clear to disable external interrupt 1. 1et0 timer 0 overflow interrupt enable bit set to enable timer 0 overflow interrupt. clear to disable timer 0 overflow interrupt. 0ex0 external interrupt 0 enable bit set to enable external interrupt 0. clear to disable external interrupt 0.
41 at8xc51snd2c 4341e?mp3?06/05 table 53. ien1 register ien1 (s:b1h) ? interrupt enable register 1 reset value = 0000 0000b 76543210 - eusb - ekb - espi ei2c emmc bit number bit mnemonic description 7- reserved the value read from this bit is always 0. do not set this bit. 6eusb usb interface interrupt enable bit set this bit to enable usb interrupts. clear this bit to disable usb interrupts. 5- reserved the value read from this bit is always 0. do not set this bit. 4 ekb keyboard interface interrupt enable bit set to enable keyboard interrupt. clear to disable keyboard interrupt. 3- reserved the value read from this bit is always 0. do not set this bit. 2espi spi controller interrupt enable bit set to enable spi interrupt. clear to disable spi interrupt. 1ei2c two wire controller interrupt enable bit set to enable two wire interrupt. clear to disable two wire interrupt. 0 emmc mmc interface interrupt enable bit set to enable mmc interrupt. clear to disable mmc interrupt.
42 at8xc51snd2c 4341e?mp3?06/05 table 54. iph0 register iph0 (s:b7h) ? interrupt priority high register 0 reset value = x000 0000b 76543210 - iphaud iphmp3 iphs ipht1 iphx1 ipht0 iphx0 bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6 iphaud audio interface interrupt priority level msb refer to table 50 for priority level description. 5iphmp3 mp3 decoder interrupt priority level msb refer to table 50 for priority level description. 4iphs serial port interrupt priority level msb refer to table 50 for priority level description. 3ipht1 timer 1 interrupt priority level msb refer to table 50 for priority level description. 2 iphx1 external interrupt 1 priority level msb refer to table 50 for priority level description. 1ipht0 timer 0 interrupt priority level msb refer to table 50 for priority level description. 0 iphx0 external interrupt 0 priority level msb refer to table 50 for priority level description.
43 at8xc51snd2c 4341e?mp3?06/05 table 55. iph1 register iph1 (s:b3h) ? interrupt priority high register 1 reset value = 0000 0000b 76543210 - iphusb - iphkb - iphspi iphi2c iphmmc bit number bit mnemonic description 7- reserved the value read from this bit is always 0. do not set this bit. 6iphusb usb interrupt priority level msb refer to table 50 for priority level description. 5- reserved the value read from this bit is always 0. do not set this bit. 4iphkb keyboard interrupt priority level msb refer to table 50 for priority level description. 3- reserved the value read from this bit is always 0. do not set this bit. 2 iphspi spi interrupt priority level msb refer to table 50 for priority level description. 1iphi2c two wire controller interrupt priority level msb refer to table 50 for priority level description. 0iphmmc mmc interrupt priority level msb refer to table 50 for priority level description.
44 at8xc51snd2c 4341e?mp3?06/05 table 56. ipl0 register ipl0 (s:b8h) - interrupt pr iority low register 0 reset value = x000 0000b 76543210 - iplaud iplmp3 ipls iplt1 iplx1 iplt0 iplx0 bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6 iplaud audio interface interrupt priority level lsb refer to table 50 for priority level description. 5iplmp3 mp3 decoder interrupt priority level lsb refer to table 50 for priority level description. 4ipls serial port interrupt priority level lsb refer to table 50 for priority level description. 3iplt1 timer 1 interrupt priority level lsb refer to table 50 for priority level description. 2 iplx1 external interrupt 1 priority level lsb refer to table 50 for priority level description. 1iplt0 timer 0 interrupt priority level lsb refer to table 50 for priority level description. 0 iplx0 external interrupt 0 priority level lsb refer to table 50 for priority level description.
45 at8xc51snd2c 4341e?mp3?06/05 table 57. ipl1 register ipl1 (s:b2h) ? interrupt priority low register 1 reset value = 0000 0000b 76543210 - iplusb - iplkb - iplspi ipli2c iplmmc bit number bit mnemonic description 7- reserved the value read from this bit is always 0. do not set this bit. 6iplusb usb interrupt priority level lsb refer to table 50 for priority level description. 5- reserved the value read from this bit is always 0. do not set this bit. 4 iplkb keyboard interrupt priority level lsb refer to table 50 for priority level description. 3- reserved the value read from this bit is always 0. do not set this bit. 2 iplspi spi interrupt priority level lsb refer to table 50 for priority level description. 1ipli2c two wire controller interrupt priority level lsb refer to table 50 for priority level description. 0 iplmmc mmc interrupt priority level lsb refer to table 50 for priority level description.
46 at8xc51snd2c 4341e?mp3?06/05 power management 2 power reduction modes are implemented in the at8xc51snd2c: the idle mode and the power-down mode. these modes are detail ed in the following sections. in addition to these power reduction modes, the clocks of the core and peripherals can be dynami- cally divided by 2 using the x2 mode detailed in section ?x2 feature?, page 12. reset in order to start-up (cold reset) or to restart (warm reset) properly the microcontroller, an high level has to be applied on the rst pin. a bad level leads to a wrong initialization of the internal registers like sfrs, program counter? and to unpredictable behavior of the microcontroller. a proper device reset initializes the at8xc51snd2c and vectors the cpu to address 0000h. rst input has a pull-down resistor allowing power-on reset by simply connecting an external capacitor to v dd as shown in figure 22. a warm reset can be applied either directly on the rst pi n or indirectly by an internal reset source such as the watchdog timer. resistor value and input characteristics are discussed in the section ?dc characteristics? of the at8xc51snd2c datasheet. the status of the port pins during reset is detailed in table 58. figure 22. reset circuitry and power-on reset table 58. pin conditions in special operating modes note: 1. refer to section ?audi o output interface?, page 73. cold reset 2 conditions are required before enabling a cpu start-up: ?v dd must reach the specified v dd range ? the level on x1 input pin must be outside the specification (v ih , v il ) if one of these 2 conditions are not met, th e microcontroller does not start correctly and can execute an instruction fe tch from anywhere in the program space. an active level applied on the rst pin must be maintained till both of the above conditions are met. a reset is active when the level v ih1 is reached and when the pulse width covers the period of time where v dd and the oscillator are not stabilized. 2 parameters have to be taken into account to determine the reset pulse width: ?v dd rise time, ? oscillator startup time. to determine the capacitor value to implement, the highest value of these 2 parameters has to be chosen. table 59 gives some ca pacitor values examples for a minimum r rst of 50 k : and different osc illator startup and v dd rise times. mode port 0 port 1 port 2 port 3 port 4 port 5 mmc audio reset floating high high high high high floating 1 idle data data data data data data data data power-down data data data data data data data data r rst rst vss to cpu core and peripherals rst vdd + power-on reset rst input circuitry p vdd from internal reset source
47 at8xc51snd2c 4341e?mp3?06/05 table 59. minimum reset capacitor value for a 50 k : pull-down resistor (1) note: 1. these values assume v dd starts from 0v to the nominal value. if the time between 2 on/off sequences is too fast, the power-supply de-coupling capacitors may not be fully discharged, leading to a bad reset sequence. warm reset to achieve a valid reset, the reset signal mu st be maintained for at least 2 machine cycles (24 oscillator clock peri ods) while the oscilla tor is running. th e number of clock periods is mode independent (x2 or x1). watchdog reset as detailed in section ?watchdog timer?, page 59, the wdt generates a 96-clock period pulse on the rst pin. in order to properly pr opagate this pulse to the rest of the applica- tion in case of external capacitor or power-supply supervisor circuit, a 1 k : resistor must be added as shown in figure 23. figure 23. reset circuitry for wdt reset-out usage reset recommendation to prevent flash corruption an example of bad initialization situation may occur in an instance where the bit enboot in auxr1 register is initialized fr om the hardware bit bljb upon reset. since this bit allows mapping of the bootloader in t he code area, a reset failure can be critical. if one wants the enboot cleared in order to unmap the boot from the code area (yet due to a bad reset) the bit enboot in sfrs may be set. if the value of program counter is accidently in the range of th e boot memory addresses then a flash access (write or erase) may corrupt the flash on-chip memory. it is recommended to use an external reset circuitry featuring power supply monitoring to prevent system malfunction during periods of insufficient power supply voltage (power supply failure, power supply switched off). idle mode idle mode is a power reduction mode that re duces the power consumption. in this mode, program execution halts. idle mode freezes the clock to the cpu at known states while the peripherals continue to be clocked (refer to section ? oscillator?, page 12). the cpu status before entering idle mode is preserved, i.e., the program counter and program status word register retain their data for the duration of idle mode. the contents of the sfrs and ram are also retained. the status of the port pins during idle mode is detailed in table 58. oscillator start-up time vdd rise time 1 ms 10 ms 100 ms 5 ms 820 nf 1.2 f 12 f 20 ms 2.7 f 3.9 f 12 f r rst rst vss to cpu core and peripherals vdd + p vdd from wdt reset source vss vdd rst 1k to other on-board circuitry
48 at8xc51snd2c 4341e?mp3?06/05 entering idle mode to enter idle mode, the user must set the idl bit in pcon register (see table 60). the at8xc51snd2c enters idle mode upon execution of the instruction that sets idl bit. the instruction that sets idl bit is the last instruction executed. note: if idl bit and pd bit are set simultaneously, the at8xc51snd2c enter power-down mode. then it does not go in idle mode when exiting power-down mode. exiting idle mode there are 2 ways to exit idle mode: 1. generate an enabled interrupt. ? hardware clears idl bit in pcon register which restores the clock to the cpu. execution resumes with the interr upt service routine. upon completion of the interrupt service routine, program execution resumes with the instruction immediately following the in struction that activated idle mode. the general-purpose flags (gf1 and gf0 in pcon register) may be used to indicate whether an interrupt occurred during normal operation or during idle mode. when idle mode is exited by an interrupt, the interrupt service routine may examine gf1 and gf0. 2. generate a reset. ? a logic high on the rst pin clears id l bit in pcon register directly and asynchronously. this restores the clock to the cpu. program execution momentarily resumes with the instruction immediately following the instruction that activated the idle mode and may continue for a number of clock cycles before the internal reset algorithm takes control. reset initializes the at8xc51snd2c and vectors the cpu to address c:0000h. note: during the time that execution resumes, the internal ram cannot be accessed; however, it is possible for the port pins to be acce ssed. to avoid unexpected outputs at the port pins, the instruction immediately following the instruction that activated idle mode should not write to a port pin or to the external ram. power-down mode the power-down mode places the at8xc51snd2c in a very low power state. power- down mode stops the oscillator and freezes all clocks at known states (refer to the sec- tion "oscillator", page 12). the cpu status prior to entering power-down mode is preserved, i.e., the program counter, program status word register retain their data for the duration of power-down mode. in addition, the sfrs and ram contents are pre- served. the status of the port pins during power-down mode is detailed in table 58. note: v dd may be reduced to as low as v ret during power-down mode to further reduce power dissipation. notice, however, that v dd is not reduced until power-down mode is invoked. entering power-down mode to enter power-down mode, set pd bit in pcon register. the at8xc51snd2c enters the power-down mode upon execution of the in struction that sets pd bit. the instruction that sets pd bit is the last instruction executed. exiting power-down mode if v dd was reduced during the power-down mode, do not exit power-down mode until v dd is restored to the normal operating level. there are 2 ways to exit the power-down mode: 1. generate an enabled external interrupt. ? the at8xc51snd2c provides capabilit y to exit from power-down using int0 , int1 , and kin0 inputs. in addition, using kin input provides high or low level exit capability (see sect ion ?keyboard interface?, page 198). hardware clears pd bit in pcon regi ster which starts the oscillator and restores the clocks to the cpu and peripherals. using intn input, execution
49 at8xc51snd2c 4341e?mp3?06/05 resumes when the input is released (see figure 24) while using kinx input, execution resumes after counting 1024 clock ens uring the oscillator is restarted properly (see figure 25). this behavior is necessary for decoding the key while it is still pressed. in bo th cases, execution resumes with the interrupt service routine. upon completion of the interrupt service routine, program execution resumes with the instruction immediately following the instruction that activated power-down mode. note: 1. the external interrupt used to exit power-down mode must be configured as level sensitive ( int0 and int1 ) and must be assigned the highest priority. in addition, the duration of the interrupt must be long enough to allow the oscillator to stabilize. the execution will only resume when the interrupt is deasserted. 2. exit from power-down by external interrupt does not affect the sfrs nor the internal ram content. figure 24. power-down exit waveform using int1:0 figure 25. power-down exit waveform using kin0 note: 1. kin0 can be high or low-level triggered. 2. generate a reset. ? a logic high on the rst pin clears pd bit in pcon register directly and asynchronously. this starts the oscilla tor and restores th e clock to the cpu and peripherals. program execution momentarily resumes with the instruction immediately following the in struction that activated power-down mode and may continue for a number of clock cycles before the internal reset algorithm takes control. rese t initializes the at8xc51snd2c and vectors the cpu to address 0000h. notes: 1. during the time that execution resume s, the internal ram cannot be accessed; how- ever, it is possible for the port pins to be accessed. to avoid unexpected outputs at the port pins, the instruction immediately fo llowing the instructi on that activated the power-down mode should not write to a port pin or to the external ram. 2. exit from power-down by reset redefines a ll the sfrs, but does not affect the internal ram content. int1:0 osc power-down phase oscillator restart phase active phase active phase kin0 1 osc power-down phase 1024 clock count active phase active phase
50 at8xc51snd2c 4341e?mp3?06/05 registers table 60. pcon register pcon (s:87h) ? power configuration register reset value = 00xx 0000b 76543210 smod1 smod0 - - gf1 gf0 pd idl bit number bit mnemonic description 7smod1 serial port mode bit 1 set to select double baud rate in mode 1,2 or 3. 6smod0 serial port mode bit 0 set to select fe bit in scon register. clear to select sm0 bit in scon register. 5 - 4 - reserved the value read from these bits is i ndeterminate. do not set these bits. 3gf1 general-purpose flag 1 one use is to indicate whether an interrupt occurred during normal operation or during idle mode. 2gf0 general-purpose flag 0 one use is to indicate whether an interrupt occurred during normal operation or during idle mode. 1pd power-down mode bit cleared by hardware when an interrupt or reset occurs. set to activate the power-down mode. if idl and pd are both set, pd takes precedence. 0idl idle mode bit cleared by hardware when an interrupt or reset occurs. set to activate the idle mode. if idl and pd are both set, pd takes precedence.
51 at8xc51snd2c 4341e?mp3?06/05 timers/counters the at8xc51snd2c implement 2 general-purp ose, 16-bit timers/counters. they are identified as timer 0 and timer 1, and can be independently configured to operate in a variety of modes as a timer or as an event counter. when operating as a timer, the timer/counter runs for a programmed length of time, then issues an interrupt request. when operating as a counter, the timer/counter counts negative transitions on an external pin. after a preset number of counts, the counter issues an interrupt request. the various operating modes of each time r/counter are described in the following sections. timer/counter operations for instance, a basic operation is timer regi sters thx and tlx (x = 0, 1) connected in cascade to form a 16-bit timer. setting the run control bit (trx) in tcon register (see table 61) turns the timer on by allowing the selected input to increment tlx. when tlx overflows it increments thx; when thx overflow s it sets the timer overflow flag (tfx) in tcon register. setting the trx does not clea r the thx and tlx timer registers. timer registers can be accessed to obtain the current count or to enter preset values. they can be read at any time but trx bit must be cleared to preset their values, otherwise, the behavior of the timer/ counter is unpredictable. the c/tx# control bit selects timer operati on or counter operation by selecting the divided-down peripheral clock or external pin tx as the source for the counted signal. trx bit must be cleared when changing the mode of operation, ot herwise the behavior of the timer/counter is unpredictable. for timer operation (c/tx# = 0), the timer register counts the divided-down peripheral clock. the timer register is incremented once every peripheral cycle (6 peripheral clock periods). the timer clock rate is f per /6, i.e., f osc /12 in standard mode or f osc /6 in x2 mode. for counter operation (c/tx# = 1), the timer register counts the negative transitions on the tx external input pin. the external in put is sampled every peripheral cycles. when the sample is high in one cycle and low in the next one, the counter is incremented. since it takes 2 cycles (12 peripheral clock pe riods) to recognize a negative transition, the maximum count rate is f per /12, i.e., f osc /24 in standard mode or f osc /12 in x2 mode. there are no restrictions on the duty cycle of the ex ternal input signal, but to ensure that a given level is sampled at leas t once before it changes, it should be held for at least one full peripheral cycle. timer clock controller as shown in figure 26, the timer 0 (ft0) and timer 1 (ft1) clocks are derived from either the peripheral clock (f per ) or the oscillator clock (f osc ) depending on the t0x2 and t1x2 bits in ckcon register. these cl ocks are issued from the clock controller block as detailed in section ?clock controlle r?, page 12. when t0x2 or t1x2 bit is set, the timer 0 or timer 1 clock frequency is fixed and equal to the oscillator clock fre- quency divided by 2. when cl eared, the timer clock frequen cy is equal to the oscillator clock frequency divided by 2 in standard mode or to the oscillator cl ock frequency in x2 mode.
52 at8xc51snd2c 4341e?mp3?06/05 figure 26. timer 0 and timer 1 clock controller and symbols timer 0 timer 0 functions as either a timer or event counter in four modes of operation. figure 27 through figure 33 show the lo gical configuration of each mode. timer 0 is controlled by the four lower bits of tmod register (see table 62) and bits 0, 1, 4 and 5 of tcon register (see table 61). tmod register selects the method of timer gating (gate0), timer or counter operation (c/t0#) and mode of operation (m10 and m00). tcon register provides timer 0 control functions: overflow flag (tf0), run control bit (tr0), interrupt flag (ie0) and interrupt type control bit (it0). for normal timer operation (gate0 = 0), setting tr0 allows tl0 to be incremented by the selected input. setting gate0 and tr0 allows external pin int0 to control timer operation. timer 0 overflow (count rolls over from all 1s to all 0s) sets tf0 flag generating an inter- rupt request. it is important to stop time r/counter before changing mode. mode 0 (13-bit timer) mode 0 configures timer 0 as a 13-bit timer which is set up as an 8-bit timer (th0 reg- ister) with a modulo 32 prescaler implemente d with the lower five bits of tl0 register (see figure 27). the upper three bits of tl0 register are indeterminate and should be ignored. prescaler overflow increments th0 register. figure 28 gives the overflow period calculation formula. figure 27. timer/counter x (x = 0 or 1) in mode 0 figure 28. mode 0 overflow period formula per clock tim0 clock osc clock 0 1 t0x2 ckcon.1 y 2 timer 0 clock timer 0 clock symbol per clock tim1 clock osc clock 0 1 t1x2 ckcon.2 y 2 timer 1 clock timer 1 clock symbol timx clock trx tcon reg tfx tcon reg 0 1 gatex tmod reg y 6 overflow timer x interrupt request c/tx# tmod reg thx (8 bits) tlx (5 bits) intx tx 6 ? (16384 ? (thx, tlx)) tfx per = f timx
53 at8xc51snd2c 4341e?mp3?06/05 mode 1 (16-bit timer) mode 1 configures timer 0 as a 16-bit timer with th0 and tl0 registers connected in cascade (see figure 29). the selected input increments tl0 register. figure 30 gives the overflow period calculation formula when in timer mode. figure 29. timer/counter x (x = 0 or 1) in mode 1 figure 30. mode 1 overflow period formula mode 2 (8-bit timer with auto- reload) mode 2 configures timer 0 as an 8-bit time r (tl0 register) that automatically reloads from th0 register (see table 63). tl0 overflow sets tf0 flag in tcon register and reloads tl0 with the contents of th0, which is preset by software. when the interrupt request is serviced, hardware clears tf0. the reload leaves th0 unchanged. the next reload value may be changed at any time by writing it to th0 register. figure 32 gives the autoreload period calculation formula when in timer mode. figure 31. timer/counter x (x = 0 or 1) in mode 2 figure 32. mode 2 autoreload period formula mode 3 (2 8-bit timers) mode 3 configures timer 0 such that registers tl0 and th0 operate as separate 8-bit timers (see figure 33). this mode is provided for applications requiring an additional 8- bit timer or counter. tl0 uses the timer 0 control bits c/t0# and gate0 in tmod reg- ister, and tr0 and tf0 in tcon register in the normal manner. th0 is locked into a timer function (counting f tf1 /6) and takes over use of the timer 1 interrupt (tf1) and run control (tr1) bits. thus, operation of ti mer 1 is restricted when timer 0 is in mode trx tcon reg tfx tcon reg 0 1 gatex tmod reg overflow timer x interrupt request c/tx# tmod reg tlx (8 bits) thx (8 bits) intx tx timx clock y 6 6 ? (65536 ? (thx, tlx)) tfx per = f timx trx tcon reg tfx tcon reg 0 1 gatex tmod reg overflow timer x interrupt request c/tx# tmod reg tlx (8 bits) thx (8 bits) intx tx timx clock y 6 tfx per = f timx 6 ? (256 ? thx)
54 at8xc51snd2c 4341e?mp3?06/05 3. figure 32 gives the autoreload period calculation formulas for both tf0 and tf1 flags. figure 33. timer/counter 0 in mode 3: 2 8-bit counters figure 34. mode 3 overflow period formula timer 1 timer 1 is identical to timer 0 except for mode 3 which is a hold-count mode. the fol- lowing comments help to understand the differences: ? timer 1 functions as either a timer or event counter in three modes of operation. figure 27 through figure 31 show the logical configuration for modes 0, 1, and 2. timer 1?s mode 3 is a hold-count mode. ? timer 1 is controlled by the four high-ord er bits of tmod register (see figure 62) and bits 2, 3, 6 and 7 of tcon register (see figure 61). tmod register selects the method of timer gating (gate1), timer or counter operation (c/t1#) and mode of operation (m11 and m01). tcon register provides timer 1 control functions: overflow flag (tf1), run control bit (tr1), interrupt flag (ie1) and interrupt type control bit (it1). ? timer 1 can serve as the baud rate generator for the serial port. mode 2 is best suited for this purpose. ? for normal timer operation (gate1 = 0), setting tr1 allows tl1 to be incremented by the selected input. setting gate1 and tr1 allows external pin int1 to control timer operation. ? timer 1 overflow (count rolls over from all 1s to all 0s) sets the tf1 flag generating an interrupt request. ? when timer 0 is in mode 3, it uses timer 1?s overflow flag (tf1) and run control bit (tr1). for this situation, use timer 1 only for applications that do not require an interrupt (such as a baud rate generator for the serial port) and switch timer 1 in and out of mode 3 to turn it off and on. ? it is important to stop the timer/counter before changing modes. tr0 tcon.4 tf0 tcon.5 int0 0 1 gate0 tmod.3 overflow timer 0 interrupt request c/t0# tmod.2 tl0 (8 bits) tr1 tcon.6 th0 (8 bits) tf1 tcon.7 overflow timer 1 interrupt request t0 tim0 clock y 6 tim0 clock y 6 tf0 per = f tim0 6 ? (256 ? tl0) tf1 per = f tim0 6 ? (256 ? th0)
55 at8xc51snd2c 4341e?mp3?06/05 mode 0 (13-bit timer) mode 0 configures timer 1 as a 13-bit timer, which is set up as an 8-bit timer (th1 reg- ister) with a modulo-32 prescaler implemented with the lower 5 bits of the tl1 register (see figure 27). the upper 3 bits of tl1 regist er are ignored. prescaler overflow incre- ments th1 register. mode 1 (16-bit timer) mode 1 configures timer 1 as a 16-bit timer with th1 and tl1 registers connected in cascade (see figure 29). the selected input increments tl1 register. mode 2 (8-bit timer with auto- reload) mode 2 configures timer 1 as an 8-bit timer (tl1 register) with automatic reload from th1 register on overflow (see figure 31). tl 1 overflow sets tf1 flag in tcon register and reloads tl1 with the contents of th1, which is preset by software. the reload leaves th1 unchanged. mode 3 (halt) placing timer 1 in mode 3 causes it to halt and hold its count. this can be used to halt timer 1 when tr1 run control bit is not av ailable i.e. when timer 0 is in mode 3. interrupt each timer handles one interrupt source that is the timer overflow flag tf0 or tf1. this flag is set every time an overflow occurs. flags are cleared when vectoring to the timer interrupt routine. interrupts are enabled by setting etx bit in ien0 register. this assumes interrupts are globally enabled by setting ea bit in ien0 register. figure 35. timer interrupt system tf0 tcon.5 et0 ien0.1 timer 0 interrupt request tf1 tcon.7 et1 ien0.3 timer 1 interrupt request
56 at8xc51snd2c 4341e?mp3?06/05 registers table 61. tcon register tcon (s:88h) ? timer/counter control register reset value = 0000 0000b 76543210 tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 bit number bit mnemonic description 7tf1 timer 1 overflow flag cleared by hardware when processor vectors to interrupt routine. set by hardware on timer/counter overflow, when timer 1 register overflows. 6tr1 timer 1 run control bit clear to turn off timer/counter 1. set to turn on timer/counter 1. 5tf0 timer 0 overflow flag cleared by hardware when processor vectors to interrupt routine. set by hardware on timer/counter overflow, when timer 0 register overflows. 4tr0 timer 0 run control bit clear to turn off timer/counter 0. set to turn on timer/counter 0. 3ie1 interrupt 1 edge flag cleared by hardware when interrupt is processed if edge-triggered (see it1). set by hardware when external interrupt is detected on int1 pin. 2it1 interrupt 1 type control bit clear to select low level active (level triggered) for external interrupt 1 (int1 ). set to select falling edge active ( edge triggered) for external interrupt 1. 1ie0 interrupt 0 edge flag cleared by hardware when interrupt is processed if edge-triggered (see it0). set by hardware when external interrupt is detected on int0 pin. 0it0 interrupt 0 type control bit clear to select low level active (level triggered) for external interrupt 0 (int0 ). set to select falling edge active ( edge triggered) for external interrupt 0.
57 at8xc51snd2c 4341e?mp3?06/05 notes: 1. reloaded from th1 at overflow. 2. reloaded from th0 at overflow. reset value = 0000 0000b table 63. th0 register th0 (s:8ch) ? timer 0 high byte register reset value = 0000 0000b table 62. tmod register tmod (s:89h) ? timer/coun ter mode control register 76543210 gate1 c/t1# m11 m01 gate0 c/t0# m10 m00 bit number bit mnemonic description 7gate1 timer 1 gating control bit clear to enable timer 1 whenever tr1 bit is set. set to enable timer 1 only while int1 pin is high and tr1 bit is set. 6c/t1# timer 1 counter/timer select bit clear for timer operation: timer 1 counts the divided-down system clock. set for counter operation: timer 1 counts negative transitions on external pin t1. 5m11 timer 1 mode select bits m11 m01 operating mode 0 0 mode 0: 8-bit timer/counter (th1) with 5-bit prescaler (tl1). 0 1 mode 1: 16-bit timer/counter. 1 0 mode 2: 8-bit auto-reload timer/counter (tl1). (1) 1 1 mode 3: timer 1 halted. retains count. 4m01 3gate0 timer 0 gating control bit clear to enable timer 0 whenever tr0 bit is set. set to enable timer/counter 0 only while int0 pin is high and tr0 bit is set. 2c/t0# timer 0 counter/timer select bit clear for timer operation: timer 0 counts the divided-down system clock. set for counter operation: timer 0 counts negative transitions on external pin t0. 1 m10 timer 0 mode select bit m10 m00 operating mode 0 0 mode 0: 8-bit timer/counter (th0) with 5-bit prescaler (tl0). 0 1 mode 1: 16-bit timer/counter. 1 0 mode 2: 8-bit auto-reload timer/counter (tl0). (2) 1 1 mode 3: tl0 is an 8-bit timer/counter. th0 is an 8-bit timer using timer 1?s tr0 and tf0 bits. 0 m00 76543210 -------- bit number bit mnemonic description 7:0 high byte of timer 0
58 at8xc51snd2c 4341e?mp3?06/05 table 64. tl0 register tl0 (s:8ah) ? timer 0 low byte register reset value = 0000 0000b table 65. th1 register th1 (s:8dh) ? timer 1 high byte register reset value = 0000 0000b table 66. tl1 register tl1 (s:8bh) ? timer 1 low byte register reset value = 0000 0000b 76543210 -------- bit number bit mnemonic description 7:0 low byte of timer 0 76543210 -------- bit number bit mnemonic description 7:0 high byte of timer 1 76543210 -------- bit number bit mnemonic description 7:0 low byte of timer 1
59 at8xc51snd2c 4341e?mp3?06/05 watchdog timer the at8xc51snd2c implement a hardware wa tchdog timer (wdt) that automatically resets the chip if it is allowed to time ou t. the wdt provides a means of recovering from routines that do not complete successfully due to software or hardware malfunctions. description the wdt consists of a 14-bit prescaler fo llowed by a 7-bit programmable counter. as shown in figure 36, the 14-bit prescale r is fed by the wdt clock detailed in section ?watchdog clock controller?, page 59. the watchdog timer reset register (wdtrst, see table 68) provides control access to the wdt, while the watchdog timer program register (wdtprg, see figure 39) pro- vides time-out period programming. three operations control the wdt: ? chip reset clears and disables the wdt. ? programming the time-out value to the wdtprg register. ? writing a specific 2-byte sequence to t he wdtrst register clears and enables the wdt. figure 36. wdt block diagram watchdog clock controller as shown in figure 37 the wdt clock (f wdt ) is derived from either the peripheral clock (f per ) or the oscillator clock (f osc ) depending on the wtx2 bit in ckcon register. these clocks are issued from the clock contro ller block as detailed in section "clock controller", page 12. when wtx2 bit is set, the wdt clock frequency is fixed and equal to the oscillator clock frequency divided by 2. when cleared, the wdt clock frequency is equal to the oscillator clock fr equency divided by 2 in standard mode or to the oscillator clock frequency in x2 mode. figure 37. wdt clock controller and symbol wto2:0 wdtprg.2:0 wdt clock y 6 system reset 1eh-e1h decoder wdtrst 14-bit prescaler rst 7-bit counter rst to internal reset en rst match set ov osc clock rst pulse generator per clock wdt clock osc clock 0 1 wtx2 ckcon.6 y 2 wdt clock wdt clock symbol
60 at8xc51snd2c 4341e?mp3?06/05 watchdog operation after reset, the wdt is disabled. the wdt is enabled by writing the sequence 1eh and e1h into the wdtrst register. as soon as it is enabled, there is no way except the chip reset to disable it. if it is not cleared using the previous sequence, the wdt overflows and forces a chip rese t. this overflow gene rates a high level 96 oscillator periods pulse on the rst pin to globally reset the application (refer to section ?power management?, page 46). the wdt time-out period can be adjusted using wto2:0 bits located in the wdtprg register accordingly to the formula shown in figure 38. in this formula, wtoval repre- sents the decimal value of wto2:0 bits. ta ble 67 reports the time-out period depending on the wdt frequency. figure 38. wdt time-out formula notes: 1. these frequencies are achieved in x1 mode or in x2 mode when wtx2 = 1: f wdt = f osc y 2. 2. these frequencies are achieved in x2 mode when wtx2 = 0: f wdt = f osc . wdt behavior during idle and power-down modes operation of the wdt during power redu ction modes deserves special attention. the wdt continues to count while the at8xc51snd2c is in idle mode. this means that you must dedicate some internal or external hardware to service the wdt during idle mode. one approach is to use a peripheral timer to generate an interrupt request when the timer overflows. the interrupt serv ice routine then clears the wdt, reloads the peripheral timer for the next service period and puts the at8xc51snd2c back into idle mode. the power-down mode stops all phase clocks . this causes the wdt to stop counting and to hold its count. the wdt resumes counting from where it left off if the power- down mode is terminated by int0 , int1 or keyboard interrupt. to ensure that the wdt does not overflow shortly after exiting the power-down mode, it is recommended to clear the wdt just before entering power-down mode. the wdt is cleared and disabled if the power-down mode is terminated by a reset. table 67. wdt time-out computation wto2 wto1 wto0 f wdt (ms) 6 mhz (1) 8 mhz (1) 10 mhz (1) 12 mhz (2) 16 mhz (2) 20 mhz (2) 0 0 0 16.38 12.28 9.83 8.19 6.14 4.92 0 0 1 32.77 24.57 19.66 16.38 12.28 9.83 0 1 0 65.54 49.14 39.32 32.77 24.57 19.66 0 1 1 131.07 98.28 78.64 65.54 49.14 39.32 1 0 0 262.14 196.56 157.29 131.07 98.28 78.64 1 0 1 524.29 393.1 314.57 262.14 196.56 157.29 1 1 0 1049 786.24 629.15 524.29 393.12 314.57 1 1 1 2097 1572 1258 1049 786.24 629.15 wdt to = f wdt 6 ? (( 2 14 ? 2 wtoval ) ? 1)
61 at8xc51snd2c 4341e?mp3?06/05 registers table 68. wdtrst register wdtrst (s:a6h write only) ? watchdog timer reset register reset value = xxxx xxxxb figure 39. wdtprg register wdtprg (s:a7h) ? watchdog timer program register reset value = xxxx x000b 76543210 -------- bit number bit mnemonic description 7 - 0 - watchdog control value 76543210 -----wto2wto1wto0 bit number bit mnemonic description 7 - 3 - reserved the value read from these bits is i ndeterminate. do not set these bits. 2 - 0 wto2:0 watchdog timer time-out selection bits refer to table 67 for time-out periods.
62 at8xc51snd2c 4341e?mp3?06/05 mp3 decoder the at8xc51snd2c implement a mpeg i/ii audio layer 3 decode r better known as mp3 decoder. in mpeg i (iso 11172-3) three layers of compression have been standardized support- ing three sampling frequencies: 48, 44.1, and 32 khz. among these layers, layer 3 allows highest compression rate of about 12 :1 while still maintaining cd audio quality. for example, 3 minutes of cd audio (16-bi t pcm, 44.1 khz) data, which needs about 32m bytes of storage, can be encoded into only 2.7m bytes of mpeg i audio layer 3 data. in mpeg ii (iso 13818-3), three additional sampling frequencies: 24, 22.05, and 16 khz are supported for low bit rates applications. the at8xc51snd2c can decode in real-time the mpeg i audio layer 3 encoded data into a pcm audio data, and also supports mpeg ii audio layer 3 additional frequencies. additional features are supported by th e at8xc51snd2c mp3 decoder such as volume control, bass, medium, and treble controls, bass boost effect and ancillary data extraction. decoder description the c51 core interfaces to the mp3 decoder through nine special function registers: mp3con, the mp3 control register (see table 73); mp3sta, the mp3 status register (see table 74); mp3dat, the mp3 data regi ster (see table 75); mp3anc, the ancillary data register (see table 77); mp3vol and mp3vor, the mp3 volume left and right control registers (see table 78 and table 79); mp3bas, mp3med, and mp3tre, the mp3 bass, medium, and treble control r egisters (see table 80, table 81, and table 82); and mpclk, the mp3 clock divider register (see table 83). figure 40 shows the mp3 decoder block diagram. figure 40. mp3 decoder block diagram mpen mp3con.7 mp3 clock audio data from c51 1k bytes 8 mpxreq mp3sta1.n header checker stereo processor huffman decoder imdct side information errxxx mp3sta.5:3 16 sub-band synthesis decoded data to audio interface anti-aliasing mpfs1:0 mp3sta.2:1 dequantizer mpver mp3sta.0 mpbbst mp3con.6 mp3vol mp3vor mp3bas mp3med mp3tre ancillary buffer mp3anc frame buffer mp3dat
63 at8xc51snd2c 4341e?mp3?06/05 mp3 data the mp3 decoder does not start any frame decoding before having a complete frame in its input buffer (1) . in order to manage the load of mp3 data in the frame buffer, a hard- ware handshake consisting of data reques t and data acknowledgment is implemented. each time the mp3 decoder needs mp3 dat a, it sets the mpreq, mpfreq and mpbreq flags respectively in mp3sta an d mp3sta1 registers. mpreq flag can gen- erate an interrupt if enabled as explained in section ?interrupt?. the cpu must then load data in the buffer by writing it through mp3dat register thus acknowledging the previ- ous request. as shown in fi gure 41, the mpfreq flag remains set while data (i.e a frame) is requested by the decoder. it is cleared when no more data is requested and set again when new data are requested. m pbreq flag toggles at every byte writing. note: 1. the first request after enable, consists in 1024 bytes of data to fill in the input buffer. figure 41. data timing diagram mp3 clock the mp3 decoder clock is generated by division of the pll clock. the division factor is given by mpcd4:0 bits in mp3clk register. figure 42 shows the mp3 decoder clock generator and its calculation formula. the mp3 decoder clock frequency depends only on the incoming mp3 frames. figure 42. mp3 clock generator and symbol as soon as the frame header has been decoded and the mpeg version extracted, the minimum mp3 input frequency must be programmed according to table 69. table 69. mp3 clock frequency mpfreq flag mpbreq flag mpreq flag cleared when reading mp3sta write to mp3dat mpeg version minimum mp3 clock (mhz) i21 ii 10.5 mpcd4:0 mp3clk mp3 decoder clock mp3clk pllclk mpcd 1 + ---------------------------- = mp3 clock mp3 clock symbol pll clock
64 at8xc51snd2c 4341e?mp3?06/05 audio controls volume control the mp3 decoder implements volume control on both right and left channels. the mp3vor and mp3vol registers allow a 32-step volume control according to table 70. table 70. volume control equalization control sound can be adjusted using a 3-band equalizer: a bass band under 750 hz, a medium band from 750 hz to 3300 hz and a treble band ov er 3300 hz. the mp3bas, mp3med, and mp3tre registers allow a 32-step gain control in each band according to table 71. table 71. bass, medium, treble control special effect the mpbbst bit in mp3con register allows en abling of a bass boos t effect with the fol- lowing characteristics: gain increase of +9 db in the frequency under 375 hz. decoding errors the three different errors that can appear during frame processing are detailed in the following sections. all these erro rs can trigger an interrupt as explained in section "inter- rupt", page 66. layer error the errsyn flag in mp3sta is set when a non-supported layer is decoded in the header of the frame that has been sent to the decoder. synchronization error the errsyn flag in mp3sta is set when no synchronization pattern is found in the data that have been sent to the decoder. crc error when the crc of a frame does not match the one calculated, the flag errcrc in mp3sta is set. in this case, depending on the crcen bit in mp3con, the frame is played or rejected. in both cases, noise may appear at audio output. vol4:0 or vor4:0 volume gain (db) 00000 mute 00001 -33 00010 -27 11110 -1.5 11111 0 bas4:0 or med4:0 or tre4:0 gain (db) 00000 - f 00001 -14 00010 -10 11110 +1 11111 +1.5
65 at8xc51snd2c 4341e?mp3?06/05 frame information the mp3 frame header contains information on the audio data contained in the frame. these informations is made available in the mp3sta register for you information. mpver and mpfs1:0 bits allow decoding of the sampling fr equency according to table 72. mpver bit gives the mpeg version (2 or 1). table 72. mp3 frame frequency sampling ancillary data mp3 frames also contain data bits called ancillary data. these data are made available in the mp3anc register for each frame. as shown in figure 43, the ancillary data are available by bytes when mpanc flag in mp3s ta register is set. mpanc flag is set when the ancillary buffer is not empty (at l east one ancillary data is available) and is cleared only when there is no more ancillary data in the bu ffer. this flag can generate an interrupt as explained in section "interrupt ", page 66. when set, software must read all bytes to empty the ancillary buffer. figure 43. ancillary data block diagram mpver mpfs1 mpfs0 fs (khz) 0 0 0 22.05 (mpeg ii) 0 0 1 24 (mpeg ii) 0 1 0 16 (mpeg ii) 011reserved 1 0 0 44.1 (mpeg i) 1 0 1 48 (mpeg i) 1 1 0 32 (mpeg i) 111reserved ancillary data to c51 8 mp3anc 8 mpanc mp3sta.7 7-byte ancillary buffer
66 at8xc51snd2c 4341e?mp3?06/05 interrupt description as shown in figure 44, the mp3 decoder implements five interrupt sources reported in errcrc, errsyn, errlay, mpreq, and mpanc flags in mp3sta register. all these sources are maskable separat ely using mskcrc, msksyn, msklay, mskreq, and mskanc mask bits respectively in mp3con register. the mp3 interrupt is enabled by setting emp3 bit in ien0 register. this assumes inter- rupts are globally enabled by setting ea bit in ien0 register. all interrupt flags but mpanc are cleared when reading mp3sta register. the mpanc flag is cleared by hardware when the ancillary buffer becomes empty.. figure 44. mp3 decoder interrupt system management reading the mp3sta register automatically clears the interrupt flags (acknowledgment) except the mpanc flags. this implies that register content must be saved and tested, interrupt flag by interrup t flag to be sure not to forget any interrupts. mp3 decoder interrupt request mpanc mp3sta.7 msklay mp3con.2 emp3 ien0.5 mskanc mp3con.4 mskreq mp3con.3 errsyn mp3sta.4 mskcrc mp3con.0 msksyn mp3con.1 mpreq mp3sta.6 errcrc mp3sta.3 errlay mp3sta.5
67 at8xc51snd2c 4341e?mp3?06/05 figure 45. mp3 interrupt service routine flow note: 1. test these bits only if needed (unmasked interrupt). data request? mpfreq = 1? layer error handler crc error handler data request handler ancillary data handler synchro error handler mp3 decoder isr read mp3sta write mp3 data to mp3dat read ann2:0 ancillary bytes from mp3anc reload mp3 frame through mp3dat load new mp3 frame through mp3dat ancillary data? (1) mpanc = 1? sync error? (1) errsyn = 1? layer error? (1) errsyn = 1?
68 at8xc51snd2c 4341e?mp3?06/05 registers table 73. mp3con register mp3con (s:aah) ? mp3 de coder control register reset value = 0011 1111b 76543210 mpen mpbbst crcen mskanc mskreq msklay msksyn mskcrc bit number bit mnemonic description 7 mpen mp3 decoder enable bit set to enable the mp3 decoder. clear to disable the mp3 decoder. 6 mpbbst bass boost bit set to enable the bass boost sound effect. clear to disable the bass boost sound effect. 5 crcen crc check enable bit set to enable processing of frame that contains crc error. frame is played whatever the error. clear to disable processing of frame that contains crc error. frame is skipped. 4 mskanc mpanc flag mask bit set to prevent the mpanc flag from generating a mp3 interrupt. clear to allow the mpanc flag to generate a mp3 interrupt. 3mskreq mpreq flag mask bit set to prevent the mpreq flag from generating a mp3 interrupt. clear to allow the mpreq flag to generate a mp3 interrupt. 2 msklay errlay flag mask bit set to prevent the errlay flag from generating a mp3 interrupt. clear to allow the errlay flag to generate a mp3 interrupt. 1 msksyn errsyn flag mask bit set to prevent the errsyn flag from generating a mp3 interrupt. clear to allow the errsyn flag to generate a mp3 interrupt. 0 mskcrc errcrc flag mask bit set to prevent the errcrc flag from generating a mp3 interrupt. clear to allow the errcrc flag to generate a mp3 interrupt.
69 at8xc51snd2c 4341e?mp3?06/05 table 74. mp3sta register mp3sta (s:c8h read only) ? mp3 decoder status register reset value = 0000 0001b table 75. mp3dat register mp3dat (s:ach) ? mp3 data register reset value = 0000 0000b 76543210 mpanc mpreq errlay errsyn errcrc mpfs1 mpfs0 mpver bit number bit mnemonic description 7mpanc ancillary data available flag set by hardware as soon as one ancilla ry data is available (buffer not empty). cleared by hardware when no more ancilla ry data is available (buffer empty). 6 mpreq mp3 data request flag set by hardware when mp3 decoder request data. cleared when reading mp3sta. 5 errlay invalid layer error flag set by hardware when an invalid layer is encountered. cleared when reading mp3sta. 4 errsyn frame synchronization error flag set by hardware when no synchronizati on pattern is encountered in a frame. cleared when reading mp3sta. 3 errcrc crc error flag set by hardware when a frame handling crc is corrupted. cleared when reading mp3sta. 2 - 1 mpfs1:0 frequency sampling bits refer to table 72 for bits description. 0 mpver mpeg version bit set by the mp3 decoder when the loaded frame is a mpeg i frame. cleared by the mp3 decoder when th e loaded frame is a mpeg ii frame. 76543210 mpd7 mpd6 mpd5 mpd4 mpd3 mpd2 mpd1 mpd0 bit number bit mnemonic description 7 - 0 mpd7:0 input stream data buffer 8-bit mp3 stream data input buffer.
70 at8xc51snd2c 4341e?mp3?06/05 table 76. mp3sta1 register mp3sta1 (s:afh) ? mp3 decoder status register 1 reset value = 0001 0001b table 77. mp3anc register mp3anc (s:adh read only) ? mp3 ancillary data register reset value = 0000 0000b table 78. mp3vol register mp3vol (s:9eh) ? mp3 volume left control register reset value = 0000 0000b 76543210 - - - mpfreq mp f req--- bit number bit mnemonic description 7 - 5 - reserved the value read from these bits is always 0. do not set these bits. 4mpfreq mp3 frame data request flag set by hardware when mp3 decoder request data. cleared when mp3 decoder no more request data . 3mpbreq mp3 byte data request flag set by hardware when mp3 decoder request data. cleared when writing to mp3dat. 2 - 0 - reserved the value read from these bits is always 0. do not set these bits. 76543210 and7 and6 and5 and4 and3 and2 and1 and0 bit number bit mnemonic description 7 - 0 and7:0 ancillary data buffer mp3 ancillary data byte buffer. 76543210 - - - vol4 vol3 vol2 vol1 vol0 bit number bit mnemonic description 7 - 5 - reserved the value read from these bits is always 0. do not set these bits. 4 - 0 vol4:0 volume left value refer to table 70 for the left channel volume control description.
71 at8xc51snd2c 4341e?mp3?06/05 table 79. mp3vor register mp3vor (s:9fh) ? mp3 volume right control register reset value = 0000 0000b table 80. mp3bas register mp3bas (s:b4h) ? mp3 bass control register reset value = 0000 0000b table 81. mp3med register mp3med (s:b5h) ? mp3 medium control register reset value = 0000 0000b 76543210 - - - vor4 vor3 vor2 vor1 vor0 bit number bit mnemonic description 7 - 5 - reserved the value read from these bits is always 0. do not set these bits. 4 - 0 vor4:0 volume right value refer to table 70 for the right channel volume control description. 76543210 - - - bas4 bas3 bas2 bas1 bas0 bit number bit mnemonic description 7 - 5 - reserved the value read from these bits is always 0. do not set these bits. 4 - 0 bas4:0 bass gain value refer to table 71 for the bass control description. 76543210 - - - med4 med3 med2 med1 med0 bit number bit mnemonic description 7 - 5 - reserved the value read from these bits is always 0. do not set these bits. 4-0 med4:0 medium gain value refer to table 71 for the medium control description.
72 at8xc51snd2c 4341e?mp3?06/05 table 82. mp3tre register mp3tre (s:b6h) ? mp3 treble control register reset value = 0000 0000b table 83. mp3clk register mp3clk (s:ebh) ? mp3 clock divider register reset value = 0000 0000b 76543210 - - - tre4 tre3 tre2 tre1 tre0 bit number bit mnemonic description 7 - 5 - reserved the value read from these bits is always 0. do not set these bits. 4-0 tre4:0 treble gain value refer to table 71 for the treble control description. 76543210 - - - mpcd4 mpcd3 mpcd2 mpcd1 mpcd0 bit number bit mnemonic description 7 - 5 - reserved the value read from these bits is always 0. do not set these bits. 4-0 mpcd4:0 mp3 decoder clock divider 5-bit divider for mp3 decoder clock generation.
73 at8xc51snd2c 4341e?mp3?06/05 audio output interface the at8xc51snd2c implement an audio output interface a llowing the audio bitstream to be output in various formats. it is compat ible with right and left justification pcm and i 2 s formats and thanks to the on-chip pll (see section ?clock controller?, page 12) allows connection of almost all of the commercial audio dac fa milies available on the market. the audio bitstream can be from 2 different types: ? the mp3 decoded bitstream coming from the mp3 decoder for playing songs. ? the audio bitstream coming from the mcu for outputting voice or sounds. description the c51 core interfaces to the audio interface through five special function registers: audcon0 and audcon1, the audio control registers (see table 86 and table 87); audsta, the audio status register (see t able 88); auddat, the audio data register (see table 89); and audclk, the audio clock divider register (see table 90). figure 46 shows the audio interface block diagram, blocks are detailed in the following sections. figure 46. audio interface block diagram aud clock udrn audsta.6 0 1 dsiz audcon0.1 dsel clock generator dclk dout sclk just4:0 audcon0.7:3 pol audcon0.2 auden audcon1.0 hlr audcon0.0 0 1 src audcon1.7 8 data converter audio data from c51 audio data from mp3 dup1:0 audcon1.2:1 16 16 sreq audsta.7 audio buffer aubusy audsta.5 data ready drqen audcon1.6 mp3 buffer decoder 16 sample request to mp3 decoder auddat
74 at8xc51snd2c 4341e?mp3?06/05 clock generator the audio interface clock is generated by divisi on of the pll clock. the division factor is given by aucd4:0 bits in clkaud register . figure 47 shows the au dio interface clock generator and its calculation formula. the audio interface clock frequency depends on the incoming mp3 frames and the audio dac used. figure 47. audio clock generator and symbol as soon as audio interface is enabled by se tting auden bit in audcon1 register, the master clock generated by the pll is output on the sclk pin which is the dac system clock. this clock is output at 256 or 384 times the sampling frequency depending on the dac capabilities. hlr bit in audcon0 register must be set according to this rate for properly generating the audio bit clock on the dclk pin and the word selection clock on the dsel pin. these clocks are not generate d when no data is available at the data converter input. for dac compatibility, the bit clock frequency is programmabl e for outputting 16 bits or 32 bits per channel using the dsiz bit in audcon0 register (see section "data con- verter", page 74), and the word selecti on signal is programmable for outputting left channel on low or high level according to pol bit in audcon0 register as shown in figure 48. figure 48. dsel output polarity data converter the data converter block converts the audio stream input from the 16-bit parallel format to a serial format. for accepting all pcm formats and i 2 s format, just4:0 bits in audcon0 register are used to shift the data output point. as shown in figure 49, these bits allow msb justification by setting ju st4:0 = 00000, lsb justification by setting just4:0 = 10000, i 2 s justification by setting just4: 0 = 00001, and more than 16-bit lsb justification by filling the low significant bits with logic 0. table 84. dac format programing examples aucd4:0 audclk audio interface clock audclk pllclk au c d1 + --------------------------- = audio clock symbol aud clock pll clock left channel right channel pol = 1 pol = 0 left channel right channel dac format pol dsiz just4:0 16-bit i 2 s 0 0 00001 > 16-bit i 2 s 0 1 00001 16-bit pcm 1 0 00000 18-bit pcm lsb justified 1 1 01110 20-bit pcm lsb justified 1 1 01100 20-bit pcm msb justified 1 1 00000
75 at8xc51snd2c 4341e?mp3?06/05 figure 49. audio output format the data converter receives its audio stream from 2 sources selected by the src bit in audcon1 register. when clea red, the audio stream comes from the mp3 decoder (see section ?mp3 decoder?, page 62) for song play ing. when set, the audio stream is com- ing from the c51 core for voice or sound playing. as soon as first audio data is input to the data converter, it enables the clock generator for generating the bit and word clocks. audio buffer in voice or sound playing mode, the audio stream comes from the c51 core through an audio buffer. the data is in 8-bit format and is sampled at 8 khz. the audio buffer adapts the sample format and rate. the sample format is extended to 16 bits by filling the lsb to 00h. rate is adapted to the dac rate by duplicating the data using dup1:0 bits in audcon1 register according to table 85. the audio buffer interfaces to the c51 core through three flags: the sample request flag (sreq in audsta register), the under-run flag (undr in audsta register) and the busy flag (aubusy in audsta register). sreq and undr can generate an interrupt request as explained in section "interrupt request", page 76. the buffer size is 8 bytes large. sreq is set when the samples number switches from 4 to 3 and reset when the samples number switches from 4 to 5; und r is set when the buffer becomes empty sig- naling that the audio interface ran out of samples; and aubusy is set when the buffer is full. dsel dclk dout msb i 2 s format with dsiz = 0 and just4:0 = 00001. lsb b14 msb lsb b14 b1 b1 dsel dclk dout msb i 2 s format with dsiz = 1 and just4:0 = 00001. lsb b14 msb lsb b14 1 2 3 13 14 15 16 1 2 3 13141516 left channel right channel 1 2 3 17 18 32 123 1718 32 dsel dclk dout b14 msb/lsb justified format with dsiz = 0 and just4:0 = 00000. msb b1 b15 msb b1 lsb lsb 1 2 3 13 14 15 16 1 2 3 13141516 left channel right channel left channel right channel dsel dclk dout 16-bit lsb justified format with dsiz = 1 and just4:0 = 10000. 11618 32 32 left channel right channel 17 31 msb b14 lsb b1 msb b14 lsb b1 11618 17 31 dsel dclk dout 18-bit lsb justified format with dsiz = 1 and just4:0 = 01110. 115 3032 left channel right channel 16 31 msb b16 b2 1 b1 lsb msb b16 b2 b1 lsb 15 30 32 16 31
76 at8xc51snd2c 4341e?mp3?06/05 table 85. sample duplication factor mp3 buffer in song playing mode, the audio stream comes from the mp3 decoder through a buffer. the mp3 buffer is used to store the decoded mp3 data and interfaces to the decoder through a 16-bit data input and data request signal. this signal asks for data when the buffer has enough space to receive new data. data request is conditioned by the dreqen bit in audcon1 register. when se t, the buffer requests data to the mp3 decoder. when cleared no more data is re quested but data are output until the buffer is empty. this bit can be used to suspend the audio generation (pause mode). interrupt request the audio interrupt request can be generated by 2 sources when in c51 audio mode: a sample request when sreq flag in audsta r egister is set to logic 1, and an under-run condition when udrn flag in audsta register is set to logic 1. both sources can be enabled separately by masking one of them using the msreq and mudrn bits in audcon1 register. a global enable of the a udio interface is provided by setting the eaud bit in ien0 register. the interrupt is requested each time one of t he 2 sources is set to one. the source flags are cleared by writing some data in the audio buffer through auddat, but the global audio interrupt flag is cleared by hardware when the interrupt service routine is executed. figure 50. audio interface interrupt system mp3 song playing in mp3 song playing mode, the operations to do are to configure the pll and the audio interface according to the dac selected. the audio clock is programmed to generate the 256fs or 384fs as explained in section "clock generator", page 74. figure 51 shows the configuration flow of the a udio interface when in mp3 song mode. dup1 dup0 factor 0 0 no sample duplication, dac rate = 8 khz (c51 rate). 0 1 one sample duplication, dac rate = 16 khz (2 x c51 rate). 1 0 2 samples duplication, dac rate = 32 khz (4 x c51 rate). 1 1 three samples duplication, dac rate = 48 khz (6 x c51 rate). sreq audsta.7 audio interrupt request udrn audsta.6 msreq audcon1.5 eaud ien0.6 mudrn audcon1.4
77 at8xc51snd2c 4341e?mp3?06/05 figure 51. mp3 mode audio configuration flow mp3 mode configuration configure interface hlr = x dsiz = x pol = x just4:0 = xxxxxb src = 0 program audio clock enable dac system clock auden = 1 wait for dac set-up time enable data request drqen = 1
78 at8xc51snd2c 4341e?mp3?06/05 registers table 86. audcon0 register audcon0 (s:9ah) ? audio interface control register 0 reset value = 0000 1000b table 87. audcon1 register audcon1 (s:9bh) ? audio interface control register 1 reset value = 1011 0010b 76543210 just4 just3 just2 just1 just0 pol dsiz hlr bit number bit mnemonic description 7 - 3 just4:0 audio stream justification bits refer to section "data converter", page 74 for bits description. 2pol dsel signal output polarity set to output the left channel on high level of dsel output (pcm mode). clear to output the left channel on the low level of dsel output (i 2 s mode). 1dsiz audio data size set to select 32-bit data output format. clear to select 16-bit data output format. 0hlr high/low rate bit set by software when the p ll clock frequency is 384fs. clear by software when the pll clock frequency is 256fs. 76543210 src drqen msreq mudrn - dup1 dup0 auden bit number bit mnemonic description 7src audio source bit set to select c51 as audio source for voice or sound playing. clear to select the mp3 decoder out put as audio source for song playing. 6 drqen mp3 decoded data request enable bit set to enable data request to the mp3 decoder and to start playing song. clear to disable data request to the mp3 decoder. 5 msreq audio sample request flag mask bit set to prevent the sreq flag from generating an audio interrupt. clear to allow the sreq flag to generate an audio interrupt. 4 mudrn audio sample under-run flag mask bit set to prevent the udrn flag from generating an audio interrupt. clear to allow the udrn flag to generate an audio interrupt. 3- reserved the value read from this bit is always 0. do not set this bit. 2 - 1 dup1:0 audio duplication factor refer to table 85 for bits description. 0auden audio interface enable bit set to enable the audio interface. clear to disable the audio interface.
79 at8xc51snd2c 4341e?mp3?06/05 table 88. audsta register audsta (s:9ch read only) ? a udio interface status register reset value = 1100 0000b table 89. auddat register auddat (s:9dh) ? audio interface data register reset value = 1111 1111b table 90. audclk register audclk (s:ech) ? audio clock divider register reset value = 0000 0000b 76543210 sreq udrn aubusy - ---- bit number bit mnemonic description 7sreq audio sample request flag set in c51 audio source mode when the audio interface request samples (buffer half empty). this bit generates an interrupt if not masked and if enabled in ien0. cleared by hardware when samples are loaded in auddat. 6 udrn audio sample under-run flag set in c51 audio source mode when the audio interface runs out of samples (buffer empty). this bit generates an interrupt if not masked and if enabled in ien0. cleared by hardware when samples are loaded in auddat. 5 aubusy audio interface busy bit set in c51 audio source mode when the audio interface can not accept more sample (buffer full). cleared by hardware when buffer is no more full. 4 - 0 - reserved the value read from these bits is always 0. do not set these bits. 76543210 aud7 aud6 aud5 aud4 aud3 aud2 aud1 aud0 bit number bit mnemonic description 7 - 0 aud7:0 audio data 8-bit sampling data for voice or sound playing. 76543210 - - - aucd4 aucd3 aucd2 aucd1 aucd0 bit number bit mnemonic description 7 - 5 - reserved the value read from these bits is always 0. do not set these bits. 4 - 0 aucd4:0 audio clock divider 5-bit divider for audio clock generation.
80 at8xc51snd2c 4341e?mp3?06/05 dac and pa interface the at8xc51snd2c implements a stereo au dio digital-to-analog converter and audio power amplifier targeted for li-ion or ni-mh battery powered devices. figure 52. audio interface block diagram dac the stereo dac section is a complete high performance, stereo, audio digital-to-analog converter delivering 93 db dynamic range. it comprises a multibit sigma-delta modula- tor with dither, continuous time analog filters and analog output drive circuitry. this architecture provides a high in sensitivity to clock jitter. t he digital interpolation filter increases the sample rate by a factor of 8 using 3 linear phase half-band filters cas- caded, followed by a first order sinc interpolat or with a factor of 8. this filter eliminates the images of baseband audio, remaining only the image at 64x the input sample rate, which is eliminated by the analog post filter . optionally, a dither signal can be added that may reduce eventual noise tones at the output. however, the use of a multibit sigma- delta modulator already provides extremely low noise tones energy. master clock is 128 up to 512 times the input data rate allowing choice of input data rate up to 50 khz, including standard audio rates of 48, 44.1, 32, 16 and 8 khz. the dac section is followed by a volume and mute control and can be simultaneously played back directly through a stereo 32 : headset pair of drivers. the stereo 32 : headset pair of drivers also includes a mixer of a li nel and liner pair of stereo inputs as well as a differential monaural au xiliary input (line level). mp3 i 2 s/pcm audio dsel dclk sclk dout audio decoder interface pa audio dac unit hsr hsl auxp auxn linel liner monop monon painp painn hpp hpn audcdin audcclk audccs serial audio interface audcdout
81 at8xc51snd2c 4341e?mp3?06/05 dac features ? 20 bit d/a conversion ? 72db dynamic range, -75db thd stereo line-in or microphone interface with 20db amplification ? 93db dynamic range, -80db thd stereo d/a conversion ? 74db dynamic range / -65db thd for 20mw output power over 32 ohm loads ? stereo, mono and reverse stereo mixer ? left/right speaker short-circuit detection flag ? differential mono auxiliary input amplifier and pa driver ? audio sampling rates (fs): 16, 22.05, 24, 32, 44.1 and 48 khz. figure 53. stereo dac functional diagram digital signals timing data interface to avoid noises at the output, the reset stat e is maintained until proper synchronism is achieved in the dac serial interface: ?dsel ?sclk ?dclk ?dout the data interface allows three different data transfer modes: digital filter digital filter volume control volume control volume control volume control spkr drv 32 dac dac pga pga spkr drv 32 hsr hsl linel liner serial to parallel interface dsel dclk + + auxn auxp aux padrv monon monop + + + dout sclk dac_olc gain 6 to -6db (3db) llig,rlig gain 20,12 to -33 db (3db) auxg gain pa gain line out gain llog, rlog 0 to -46.5db (1.5db) master playback gain 12 to -34db (1.5db)
82 at8xc51snd2c 4341e?mp3?06/05 figure 54. 20 bit i2s justified mode figure 55. 20 bit msb justified mode figure 56. 20 bit lsb justified mode the selection between modes is done using the dintsel 1:0 in dac_misc register (table 112.) according with the following table: the data interface always works in slave mode. this means that the dsel and the dclk signals are provided by microcontroller audio data interface. serial audio dac interface the serial audio dac interface is a sync hronous peripheral interface (spi) in slave mode: ? audcdin: is used to transf er data in series from the master to the slave dac. it is driven by the master. ? audcdout: is used to transfer data in se ries from the slave dac to the master. it is driven by the selected slave dac. ? serial clock (audcclk): it is used to synchronize the data tr ansmission both in and out the devices through the audcdin and audcdout lines. note: refer to table 101. for dac spi interface description r1 r0 l(n-1) l(n-2) l(n-3) ... l2 l1 l0 r(n-1) r(n-2) r(n-3) ... r2 r1 r0 sclk dsel dout r0 l(n-1) l(n-2) l(n-3) ... l2 l1 l0 r(n-1) r(n-2) r(n-3) ... r2 r1 r0 l(n-1) sclk dsel dout r0 l(n-1) l(n-2) ... l1 l0 r(n-1) r(n-2) ... r1 r0 l(n-1) sclk dsel dout dintsel 1:0 format 00 i2s justified 01 msb justified 1x lsb justified
83 at8xc51snd2c 4341e?mp3?06/05 figure 57. serial audio interface protocol is as following to access dac registers: figure 58. dac spi interface dac interface spi protocol on audcdin, the first bit is a read/write bit. 0 indicates a write operation while 1 is for a read operation. the 7 following bits are used for the register address and the 8 last ones are the write data. for both address and data, the most significant bit is the first one. in case of a read operation, audcdout prov ides the contents of the read register, msb first. the transfer is enabled by the audccs signal active low. the interface is resetted at every rising edge of audccs in order to come back to an idle state, even if the transfer does not succeed. the dac interface spi is synchronized with the serial clock audc- audio pa audio dac audcdin audcclk audccs serial audio interface audcdout rw a6 a5 a4 a3 a2 a1 d7 d6 d5 d3 d7 d6 d5 d4 d1 d0 d2 d3 d0 d1 d2 d4 a0 a udcdout a udcdin a udcclk a udccs
84 at8xc51snd2c 4341e?mp3?06/05 clk. falling edge latches audcdin input and rising edge shifts audcdout output bits. note that the dlck must run during any dac spi interface access (read or write). figure 59. dac spi interface timings table 91. dac spi interface timings thsdi tssen tc twl twh thsen tssdi a udcdout audcdin audcclk tdsdo thsdo audccs timing parameter description min max tc audcclk min period 150 ns - twl audcclk min pulse width low 50 ns - twh audcclk min pulse width high 50 ns - tssen setup time audccs falling to audcclk rising 50 ns - thsen hold time audcclk falling to audccs rising 50 ns - tssdi setup time audcdin valid to audcclk falling 20 ns - thsdi hold time audcclk falling to audcdin not valid 20 ns - tdsdo delay time audcclk rising to audcdout valid - 20 ns thsdo hold time audcclk rising to audcdout not valid 0 ns -
85 at8xc51snd2c 4341e?mp3?06/05 dac register tables table 92. dac register address dac gain the dac implements severals gain control: line-in (table 93.), master playback (), line- out (table 96.). address register name access reset state 00h dac_ctrl dac control read/write 00h 01h dac_llig dac left line in gain read/write 05h 02h dac_rlig dac right line in gain read/write 05h 03h dac_lpmg dac left master playback gain read/write 08h 04h dac_rpmg dac right master playback gain read/write 08h 05h dac_llog dac left line out gain read/write 00h 06h dac_rlog dac right line out gain read/write 00h 07h dac_olc dac output level control read/write 22h 08h dac_mc dac mixer control read/write 09h 09h dac_csfc dac clock and sampling frequency control read/write 00h 0ah dac_misc dac miscellaneous read/write 00h 0ch dac_prech dac precharge control read/write 00h 0dh dac_auxg dac auxilary input gain control read/write 05h 10h dac_rst dac reset read/write 00h 11h pa_crtl power amplifier control read/write 00h table 93. line-in gain llig 4:0 rlig 4:0 gain (db) 00000 20 00001 12 00010 9 00011 6 00100 3 00101 0 00110 -3 00111 -6 01000 -9 01001 -12 01010 -15 01011 -18 01100 -21
86 at8xc51snd2c 4341e?mp3?06/05 01101 -24 01110 -27 01111 -30 10000 -33 10001 < -60 table 94. master playback gain lmpg 5:0 rmpg 5:0 gain (db) 000000 12.0 000001 10.5 000010 9.0 000011 7.5 000100 6.0 000101 4.5 000110 3.0 000111 1.5 001000 0.0 001001 -1.5 001010 -3.0 001011 -4.5 001100 -6.0 001101 -7.5 001110 -9.0 001111 -10.5 010000 -12.0 010001 -13.5 010010 -15.0 010011 -16.5 010100 -18.0 010101 -19.5 010110 -21.0 010111 -22.5 011000 -24.0 011001 -25.5 table 93. line-in gain (continued)
87 at8xc51snd2c 4341e?mp3?06/05 011010 -27.0 011011 -28.5 011100 -30.0 011101 -31.5 011110 -33.0 011111 -34.5 100000 mute table 95. line-out gain llog 5:0 rlog 5:0 gain (db) 000000 0.0 000001 -1.5 000010 -3.0 000011 -4.5 000100 -6.0 000101 -7.5 000110 -9.0 000111 -10.5 001000 -12.0 001001 -13.5 001010 -15.0 001011 -16.5 001100 -18.0 001101 -19.5 001110 -21.0 001111 -22.5 010000 -24.0 010001 -25.5 010010 -27.0 010011 -28.5 010100 -30.0 010101 -31.5 010110 -33.0 table 94. master playback gain (continued) lmpg 5:0 rmpg 5:0 gain (db)
88 at8xc51snd2c 4341e?mp3?06/05 table 96. dac output level control digital mixer control the audio dac features a digital mixer that allows the mixing and selection of multiple input sources. the mixing / multiplexing functions are descr ibed in the following table according with the next figure: figure 60. mixing / multiplexing functions note: whenever the two mixer inputs are selected, a ?6 db gain is applied to the output signal. whenever only one input is selected, no gain is applied. 010111 -34.5 011000 -36.0 011001 -37.5 011010 -39.0 011011 -40.5 011100 -42.0 011101 -43.5 011110 -45.0 011111 -46.5 100000 mute lolc 2:0 rolc 2:0 gain (db) 000 6 001 3 010 0 011 -3 100 -6 table 95. line-out gain (continued) volume control volume control volume control volume control + + 1 2 2 1 left channel right channel from digital filters to dacs
89 at8xc51snd2c 4341e?mp3?06/05 note: refer to dac_mc register table 110. for signal description master clock and sampling frequency selection the following table describes the different modes available for master clock and sam- pling frequency selection by setting ovrsel bit in dac_csfc register (refer to table 111.). table 97. master clock selection the selection of input sample size is done using the nbits 1:0 in dac_misc register (refer to table 112.) according to table 98. table 98. input sample size selection the selection between modes is done using dintsel 1:0 in dac_misc register (refer to table 112.) according to table 99. table 99. format selection de-emphasis and dither enable the circuit features a de-emphasis filter for the playback channel. to enable the de- emphasis filtering, deempen must be set to high. likewise, the dither option (added in the playback channel) is enabled by setting the dithen signal to high. signal description lmsmin1 left channel mono/stereo mixer left mixed input enable ? high to enable, low to disable lmsmin2 left channel mono/stereo mixer right mixed input enable ? high to enable, low to disable rmsmin1 right channel mono/stereo mixer left mixed input enable ? high to enable, low to disable rmsmin2 right channel mono/stereo mixer right mixed input enable ? high to enable, low to disable ovrsel master clock 0256 x fs 1384 x fs nbits 1:0 format 00 16 bits 01 18 bits 10 20 bits dintsel 1:0 format 00 i2s justified 01 msb justified 1x lsb justified
90 at8xc51snd2c 4341e?mp3?06/05 table 100. dac auxlilary input gain auxg 4:0 gain (db) 00000 20 00001 12 00010 9 00011 6 00100 3 00101 0 00110 -3 00111 -6 01000 -9 01001 -12 01010 -15 01011 -18 01100 -21 01101 -24 01110 -27 01111 -30 10000 -33 10001 <-60
91 at8xc51snd2c 4341e?mp3?06/05 register table 101. auxcon register auxcon (s:90h) ? auxiliary control register reset value = 1111 1111b 76 5 4 3210 sda scl - audcdout audcdin audcclk audccs kin0 bit number bit mnemonic description 7sda twi serial data sda is the bidirectional two wire data line. 6scl twi serial clock when twi controller is in master mode, scl outputs the serial clock to the slave peripherals. when twi controller is in slave mode, scl receives clock from the master controller. 5 - not used. 4 audcdout audio dac spi data output . 3 audcdin audio dac spi data input 2 audcclk audio dac spi clock 1 audccs audio dac chip select set to deselect dac clear to select dac 0kin0 keyboard input interrupt .
92 at8xc51snd2c 4341e?mp3?06/05 table 102. dac control register regi ster - dac_ctrl (00h) reset value = 00000000b table 103. dac left line in gain register - dac_llig (01h) reset value = 00000101b 76543210 onpadrv onauxin ondacr ondacl onlnor onlnol onlnir onlnil bit number bit mnemonic description 7onpadrv differential mono pa driver clear to power down. set to power up. 6onauxin differential mono auxiliary input amplifier clear to power down. set to power up. 5ondacr right channel dac clear to power down. set to power up. 4ondacl left channel dac clear to power down. set to power up. 3 onlnor right channel line out driver clear to power down. set to power up. 2onlnol left channel line out driver clear to power down. set to power up. 1 onlnir right channel line in amplifier clear to power down. set to power up. 0onlnil left channel line in amplifier clear to power down. set to power up. 76543210 - - - llig4 llig3 llig2 llig1 llig0 bit number bit mnemonic description 7:5 - not used 4:0 llig 4:0 left channel line in analog gain selector
93 at8xc51snd2c 4341e?mp3?06/05 table 104. dac right line in gain re gister - dac_rlig (02h) reset value = 0000101b table 105. dac left master playback gain register - dac_lmpg (03h) reset value = 00001000b table 106. dac right master playback gain register - dac_rmpg (04h) reset value = 00001000b table 107. dac left line out gain register - dac_llog (05h) reset value = 00000000b 76543210 - - - rlig4 rlig3 rlig2 rlig1 rlig0 bit number bit mnemonic description 7:5 - not used 4:0 rlig 4:0 right channel line in analog gain selector 76543210 - - lmpg5 lmpg4 lmpg3 lmpg2 lmpg1 lmpg0 bit number bit mnemonic description 7:6 - not used 5:0 lmpg 5:0 left channel master playback digital gain selector 76543210 - - rmpg5 rmpg4 rmpg3 rmpg2 rmpg1 rmpg0 bit number bit mnemonic description 7:6 - not used 5:0 rmpg 5:0 right channel master playback digital gain selector 76543210 -- llog5 llog4 llog3 llog2 llog1 llog0 bit number bit mnemonic description 7:6 - not used 5:0 llog 5:0 left channel line out digital gain selector
94 at8xc51snd2c 4341e?mp3?06/05 table 108. dac rigth line out gain r egister - dac_rlog (06h) reset value = 00000000b table 109. dac output level control register - dac_olc (07h) reset value = 00100010b 76543210 - - rlog5 rlog4 rlog3 rlog2 rlog1 rlog0 bit number bit mnemonic description 7:6 - not used 5:0 rlog 5:0 right channel line out digital gain selector 76543210 rshort rolc2 rloc1 rloc0 lshort lolc2 lolc1 lolc0 bit number bit mnemonic description 7rshort right channel short circuit indicator (persistent; after being set, bit is not cleared automatically even after the s hort circuit is eliminated; must be cleared by reset cycle or direct register write operation) 6:4 rolc 2:0 right channel output level control selector 3lshort left channel short circuit indicator ( persistent; after being set, bit is not cleared automatically even after the s hort circuit is eliminated; must be cleared by reset cycle or direct register write operation) 2:0 lolc 2:0 left channel output level control selector
95 at8xc51snd2c 4341e?mp3?06/05 table 110. dac mixer control register - dac_mc (08h) reset value = 00001001b table 111. dac mixer control register - dac_csfc (09h) reset value = 00000000b 76 5 4 3 2 1 0 - - invr invl rmsmin2 rmsmin1 lmsmin2 lmsmin1 bit number bit mnemonic description 7:6 - not used 5invr right channel mixer output invert set to enable. clear to disable. 4invl left channel mixer output invert. set to enable. clear to disable. 3 rmsmin2 right channel mono/stereo mixer right mixed input enable set to enable. clear to disable. 2 rmsmin1 right channel mono/stereo mixer left mixed input enable set to enable. clear to disable. 1lmsmin2 left channel mono/stereo mixer right mixed input enable set to enable. clear to disable. 0lmsmin1 left channel mono/stereo mixer left mixed input enable set to enable. clear to disable. 76543210 - - - ovrsel - - - - bit number bit mnemonic description 7:5 - not used 4 ovrsel master clock selector clear for 256 x fs. set for 384 x fs. 3:0 - not used
96 at8xc51snd2c 4341e?mp3?06/05 table 112. dac miscellaneous regist er - dac_ misc (0ah) reset value = 00000010b table 113. dac precharge control register - dac_ prech (0ch) reset value = 00000000b 76 5 4 3 2 1 0 - - dintsel1 dintsel0 dithen deempen nbits1 nbits0 bit number bit mnemonic description 7 - not used 6 - not used 5:4 dintsel1:0 i2s data format selector 3 dithen dither enable (clear this bit to disable, set to enable) 2 deempen de-emphasis enable (clear this bit to disable, set to enable) 1:0 nbits 1:0 data interface word length 76543210 prchar gepadrv - prchar geauxin - prchar gelnor prchar gelnol prchar gelnil prchar gelnil prchar ge onmstr bit number bit mnemonic description 7 prchargepad rv differential mono pa driver pre-charge. set to charge. 6 prchargeaux in differential mono auxiliary input pre-charge. set to charge. 5 prchargelno r right channel line out pre-charge. set to charge. 4 prchargelno l left channel line out pre-charge. set to charge. 3 prchargelni r right channel line in pre-charge. set to charge. 2 prchargelnil left channel line in pre-charge set to charge. 1 prcharge master pre-charge set to charge. 0onmstr master power on control clear to power down. set to to power up.
97 at8xc51snd2c 4341e?mp3?06/05 table 114. dac auxilary input gain re gister - dac_ auxg (0dh)l reset value = 0000101b dac reset register - dac_ rst (10h) reset value = 00000000b note: refer to audio dac startup sequence. 76543210 - - - auxg4 auxg3 auxg2 auxg1 auxg0 bit number bit mnemonic description 7:5 - not used 4:0 auxg 4:0 differential mono auxiliary input analog gain selector 76543210 -----resmaskresfilzrstz bit number bit mnemonic description 7:3 - not used. 2 resmask active high reset mask of the audio codec 1 resfilz active low reset of the audio codec filter 0rstz active low reset of the audio codec
98 at8xc51snd2c 4341e?mp3?06/05 power amplifier high quality mono output is provided. the dac output is connected through a buffer stage to the input of the audio power amplifier, using two coupling capacitors the mono buffer stage also includes a mixer of the linel and liner inputs as well as a dif- ferential monaural auxiliary input (line level) which can be, for example, the output of a voice codec output driver in mobile phones. in the full power mode, the power amp lifier is capable of driving an 8 : loudspeaker at maximum power of 440mw, making it suitable as a handsfree speaker driver in wire- less handset application. the low power mode is designed to be switched from the handsfree mode to the nor- mal earphone/speaker mode of a telephone handset. the audio power amplifier is not internally protected against shor t-circuit. the user should avoid any short-circuit on the load. pa features ? 0.44w on 8 : load ? low power mode for earphone ? programmable gain (-22 to +20 db) ? fully differential struct ure, input and output table 115. pa gain apagain 3:0 gain (db) 0000 -22 0001 20 0010 17 0011 14 0100 11 0101 8 0110 5 0111 2 1000 -1 1001 -4 1010 -7 1011 -10 1100 -13 1101 -16 1110 -19 1111 -22
99 at8xc51snd2c 4341e?mp3?06/05 table 116. pa operating mode table 117. pa low power mode audio supplies and start-up in operating mode audvbat (s upply of the audio power am plifier) must be between 3v and 5,5v. audvdd, hsvdd and vdd must be inferior or equal to audvbat. a typical application is audvbat connect ed to a battery and audvdd, hsvdd and vdd supplied by regulators. audvbat must be present at the same time or befo re audvdd, hsvdd and vdd. audrst must be active low (0) until the voltages are not etab lished and reach the proper values. to avoid noise issues, it is recommended to use ceramic decoupling capacitors for each supply closed to the package. the track of t he supplies must be optimized to minimize the resistance especially on audvbat where al l the current from the power amplifier comes from. note: refer to the application diagram. audio dac start-up sequence in order to minimize any audio output noise during the start-up, the following sequence should be applied. example of power-on: path dac to headset output ? desassert the reset: write 07h at address 10h. ? all precharge and master on: write ffh at address 0ch. ? line out on: write 30h at address 00h. ? delay 500 ms. ? precharge off: write 0ch at address 01h. ? delay 1 ms. ? line out on, dac on: write 3ch at address 00h. example of power-off: path dac to headset output ? dac off: write 30h at address 00h. ? master off: write 00h at address 0ch. ? delay 1 ms. ? all off: write 00h at address 00h apaon apaprech operating mode 0 0 stand-by 0 1 input capacitors precharge 1 0 active mode 1 1 forbidden state apalp power mode 0 low power mode 1 high power mode
100 at8xc51snd2c 4341e?mp3?06/05 example start i2s ?start dclk. ? rstmask=1. ? resfilz=0 and rstz=0. ? resfilz=1 and rstz=1. ? rstmask=0. ? delay 5 ms. ? ondacl=1 and ondacr=1. ? program all dac settings: audio format, gains... example stop i2s: ? dac off: ondacl=0 and ondacr=0. ? stop i2s and dlck. audio pa sequence pa power-on sequence to avoid an audible ?click? at start-up, the input capacitors have to be pre-charged before the power amplifier. pa power-off sequence to avoid an audible ?click? at power-off, the gain should be set to the minimum gain (- 22db) before setting the power amplifier. precharge control the power up of the circuit can be perfo rmed independently for several blocks. the sequence flow starts by setting to high the block specific fastchar ge control bit and sub- sequently the associated power control bit. once the power control bit is set to high, the fast charging starts. this action begins a user controlled fastcharge cycle. when the fastcharge period is over, the user must reset the associated fastcharge bit and the block is ready for use. if a power contro l bit is cleared a new power up sequence is needed. the several blocks with independ ent power control are identifi ed in table 118. the table describes the power on control a nd fastcharge bits for each block. table 118. precharge and power control note: note that all block can be precharged simultaneously. powered up block power on control bit precharge control bit vref & vcm generator onmstr prcharge (reg 12; bit 1) left line in amplifier onlnil prchargelnil right line in amplifier onlnir prchargelnir left line out amplifier onlnol prchargelnol right line out amplifier onlnor prchargelnor left d-to-a converter ondacl not needed right d-to-a converter ondacr not needed auxiliary input amplifier onauxin prchargeauxin pa driver output onpadrv prchargepadrv
101 at8xc51snd2c 4341e?mp3?06/05 register table 119. pa control register - pa_ctrl (11h)l reset value = 00000000b 76 5 4 3 2 1 0 -apaon apaprec h apalp apagain3 apagain2 apagain1 apagain0 bit number bit mnemonic description 7 - not used 6 apaon audio power amplifier on bit 5 apaprech audio power amplifier precharge bit 4 apalp audio power amplifier low power bit 3:0 apagain3:0 audio power amplifier gain
102 at8xc51snd2c 4341e?mp3?06/05 universal serial bus the at8xc51snd2c implements a usb devi ce controller supporting full speed data transfer. in addition to the default control end point 0, it provides 2 other endpoints, which can be configured in control, bulk, interrupt or isochronous modes: ? endpoint 0: 32-byte fifo, default control endpoint ? endpoint 1, 2: 64-byte ping-pong fifo, this allows the firmware to be developed c onforming to most us b device classes, for example: ? usb mass storage class bulk-only transport, revision 1.0 - september 31, 1999 ? usb human interface device class, version 1.1 - april 7, 1999 ? usb device firmware upgrade class, revision 1.0 - may 13, 1999 usb mass storage class bulk-only transport within the bulk-only framework, the control endpoint is only used to transport class- specific and standard usb requests for device set-up and configuration. one bulk-out endpoint is used to transport commands and data from the host to the device. one bulk in endpoint is used to transport status and data from the device to the host. the following at8xc51snd2c configuration adheres to those requirements: ? endpoint 0: 32 bytes, control in-out ? endpoint 1: 64 bytes, bulk-in ? endpoint 2: 64 bytes, bulk-out usb device firmware upgrade (dfu) the usb device firmware update (dfu) protocol can be used to upgrade the on-chip flash memory of the at89c51snd2c. this allows installing product enhancements and patches to devices that ar e already in the field. 2 different configurations and descriptor sets are used to support dfu fu nctions. the run-time configuration co-exist with the usual functions of the device, wh ich is usb mass storage for at89c51snd2c. it is used to initiate dfu from the no rmal operating mode. the dfu configuration is used to perform the firmware update after device re-configuration and usb reset. it excludes any other function. only the default control pipe (endpoint 0) is used to support dfu services in bo th configurations. the only possible value for t he maxpacketsize in the dfu configuration is 32 bytes, which is the size of the fifo implemented for endpoint 0.
103 at8xc51snd2c 4341e?mp3?06/05 description the usb device controller provides the hardware that the at8xc51snd2c needs to interface a usb link to a data flow stored in a double port memory. it requires a 48 mhz reference clock provided by the clock controller as detailed in sec- tion "", page 103. this clock is used to generate a 12 mhz full speed bit clock from the received usb differential data flow and to transmit data according to full speed usb device tolerance. clock recovery is done by a digital phase locked loop (dpll) block. the serial interface engine (sie) block perf orms nrzi encoding and decoding, bit stuff- ing, crc generation and checking, and the serial-parallel data conversion. the universal function interface (ufi) contro ls the interface between the data flow and the dual port ram, but also the interface with the c51 core itself. figure 63 shows how to connec t the at8xc51snd2c to the usb connector. d+ and d- pins are connected through 2 termination resi stors. a pull-up resistor is implemented on d+ to inform the host of a full speed devic e connection. value of these resistors is detailed in the section ?dc characteristics?. figure 61. usb device controller block diagram figure 62. usb connection clock controller the usb controller clock is generated by divisi on of the pll clock. the division factor is given by usbcd1:0 bits in usbclk regist er (see table 135). figure 63 shows the usb controller clock generator and its calculat ion formula. the usb controller clock fre- quency must always be 48 mhz. usb clock 48 mhz 12 mhz d+ d- dpll sie ufi usb buffer to/from c51 core d+ d- vbus gnd d+ d- vss to p o w e r r usb r usb vdd supply r fs
104 at8xc51snd2c 4341e?mp3?06/05 figure 63. usb clock generator and symbol usbcd1:0 usbclk 48 mhz usb clock usbclk pllclk usbcd 1 + -------------------------------- = usb clock usb clock symbol pll clock
105 at8xc51snd2c 4341e?mp3?06/05 serial interface engine (sie) the sie performs the following functions: ? nrzi data encoding and decoding. ? bit stuffing and unstuffing. ? crc generation and checking. ? acks and nacks automatic generation. ? token type identifying. ? address checking. ? clock recovery (using dpll). figure 64. sie block diagram 8 start of packet detector clock recover sync detector pid decoder address decoder serial to parallel converter crc5 & crc16 generator/check usb pattern generator parallel to serial converter bit stuffing nrzi converter crc16 generator nrzi ? nrz bit unstuffing packet bit counter end of packet detector usb clock 48 mhz sysclk data in d+ d- (12 mhz) 8 data out
106 at8xc51snd2c 4341e?mp3?06/05 function interface unit (ufi) the function interface unit provides th e interface between the at8xc51snd2c and the sie. it manages transactions at the packet level with minimal intervention from the device firmware, which reads and writes the endpoint fifos. figure 66 shows typical usb in and out transactions reporting the split in the hard- ware (ufi) and software (c51) load. figure 65. ufi block diagram figure 66. usb typical transaction load to/from c51 core endpoint control c51 side endpoint control usb side endpoint 2 endpoint 1 endpoint 0 usbcon usbint usbien uepint uepien uepnum uepstax usbaddr uepconx uepdatx ueprst ubyctx ufnumh ufnuml asynchronous information transfer control fsm to/from sie 12 mhz dpll out transactions: host ufi c51 out data0 (n bytes) ack endpoint fifo read (n bytes) out data1 nack out data1 ack in transactions: host ufi c51 in ack endpoint fifo write in data1 nack c51 interrupt in data1 c51 interrupt endpoint fifo write
107 at8xc51snd2c 4341e?mp3?06/05 configuration general configuration ? usb controller enable before any usb transaction, the 48 mhz required by the usb controller must be correctly generated (see ?clock controller? on page 19). the usb controller should be then enabled by setting the eusb bit in the usbcon register. ? set address after a reset or a usb reset, the software has to set the fen (function enable) bit in the usbaddr register. this action will allo w the usb controller to answer to the requests sent at the address 0. when a set_address request has been received, the usb controller must only answer to the address defined by the request. the new address should be stored in the usbaddr register. the fen bit and the fadden bit in the usbcon register should be set to allow the usb controller to answer only to requests sent at the new address. ? set configuration the confg bit in the usbcon register should be set after a set_configuration request with a non-zero value. otherwise, this bit should be cleared. endpoint configuration ? selection of an endpoint the endpoint register access is performed using the uepnum register. the registers ? uepstax ? uepconx ? uepdatx ? ubyctx theses registers correspond to the endpoint whose number is stored in the uep- num register. to select an endpoint, the firmware has to write the endpoint number in the uepnum register. figure 67. endpoint selection uepnum endpoint 0 endpoint 2 uepsta0 uepcon0 uepdat0 uepsta2 uepcon2 uepdat2 0 1 2 sfr registers uepstax uepconx uepdatx x ubyct0 ubyct2 ubyctx
108 at8xc51snd2c 4341e?mp3?06/05 ? endpoint enable before using an endpoint, this must be ena bled by setting the epen bit in the uep- conx register. an endpoint which is not enabled won?t ans wer to any usb request. the default control endpoint (endpoint 0) should always be enabled in order to answer to usb standard requests. ? endpoint type configuration all standard endpoints can be configured in control, bulk, interrupt or isochronous mode. the ping-pong endpoints can be configured in bulk, interrupt or isochronous mode. the configuration of an endpoint is performed by setting the field eptype with the following values: ? control: eptype = 00b ? isochronous: eptype = 01b ? bulk: eptype = 10b ? interrupt: eptype = 11b the endpoint 0 is the default control endpoint and should always be configured in control type. ? endpoint direction configuration for bulk, interrupt and isochronous endpoints, the direction is defined with the epdir bit of the uepconx regist er with the following values: ? in: epdir = 1b ? out: epdir = 0b for control endpoints, the epdir bit has no effect. ? summary of endpoint configuration: do not forget to select the correct endpoint number in the uepnum register before accessing endpoint specific registers. table 120. summary of endpoint configuration endpoint configuratio n epen epdir eptype uepconx disabled 0b xb xxb 0xxx xxxb control 1b xb 00b 80h bulk-in 1b 1b 10b 86h bulk-out 1b 0b 10b 82h interrupt-in 1b 1b 11b 87h interrupt-out 1b 0b 11b 83h isochronous-in 1b 1b 01b 85h isochronous-out 1b 0b 01b 81h
109 at8xc51snd2c 4341e?mp3?06/05 ? endpoint fifo reset before using an endpoint, its fifo should be reset. this action resets the fifo pointer to its original value, resets the byte counter of the endpoint (ubyctx regis- ter), and resets the data toggle bit (dtgl bit in uepconx). the reset of an endpoint fifo is performed by setting to 1 and resetting to 0 the corresponding bit in the ueprst register. for example, in order to reset the endpoint number 2 fifo, write 0000 0100b then 0000 0000b in the ueprst register. note that the endpoint reset doesn?t reset the bank number for ping-pong endpoints. read/write data fifo read data fifo the read access for each out endpoint is performed using the uepdatx register. after a new valid packet has been received on an endpoint, the data are stored into the fifo and the byte counter of the endpoint is updated (ubyctx registers). the firmware has to store the endpoint byte counter before any access to the endpoint fifo. the byte counter is not updated when reading the fifo. to read data from an endpoint, select the correct endpoint number in uepnum and read the uepdatx register. this action automatically decreases the corresponding address vector, and the next data is th en available in the uepdatx register. write data fifo the write access for each in endpoint is performed using the uepdatx register. to write a byte into an in endpoint fifo, select the correct endpoint number in uep- num and write into the uepdatx register. the corresponding address vector is automatically increased, and another write can be carried out. warning 1: the byte counter is not updated. warning 2: do not write more bytes than supported by the corresponding endpoint. fifo mapping figure 68. endpoint fifo configuration uepnum endpoint 0 endpoint 2 uepsta0 uepcon0 uepdat0 uepsta2 uepcon2 uepdat2 0 1 2 sfr registers uepstax uepconx uepdatx x ubyct0 ubyct2 ubyctx
110 at8xc51snd2c 4341e?mp3?06/05 bulk/interrupt transactions bulk and interrupt transactions are managed in the same way. bulk/interrupt out transactions in standard mode figure 69. bulk/interrupt out transactions in standard mode an endpoint should be first enabled and configured before being able to receive bulk or interrupt packets. when a valid out packet is received on an endpoint, the rxoutb0 bit is set by the usb controller. this triggers an interrupt if enabled. the firmware has to select the cor- responding endpoint, store the number of da ta bytes by reading the ubyctx register. if the received packet is a zlp (zero length pa cket), the ubyctx register value is equal to 0 and no data has to be read. when all the endpoint fifo bytes have been read, the firmware should clear the rxoutb0 bit to allow the usb controller to accept the next out packet on this end- point. until the rxoutb0 bit has been cleared by the firmware, the usb controller will answer a nak handshake for each out requests. if the host sends more bytes than support ed by the endpoint fifo, the overflow data won?t be stored, but the usb c ontroller will consider that the packet is valid if the crc is correct and the endpoint byte counter contains the number of bytes sent by the host. out data0 (n bytes) ack host ufi c51 endpoint fifo read byte 1 out data1 nak rxoutb0 endpoint fifo read byte 2 endpoint fifo read byte n clear rxoutb0 out data1 nak out data1 ack rxoutb0 endpoint fifo read byte 1
111 at8xc51snd2c 4341e?mp3?06/05 bulk/interrupt out transactions in ping-pong mode figure 70. bulk/interrupt out transactions in ping-pong mode an endpoint should be first enabled and configured before being able to receive bulk or interrupt packets. when a valid out packet is received on t he endpoint bank 0, the rxoutb0 bit is set by the usb controller. this triggers an interrupt if enabled. the firmware has to select the corresponding endpoint, store the number of data bytes by reading the ubyctx regis- ter. if the received packet is a zlp (zero length packet), the ubyctx register value is equal to 0 and no data has to be read. when all the endpoint fifo bytes have been read, the firmware should clear the rxoub0 bit to allow the usb controller to accept the next out packet on the endpoint bank 0. this action switches the endpoint bank 0 and 1. until the rxoutb0 bit has been cleared by the firmwar e, the usb controller will answe r a nak handshake for each out requests on the bank 0 endpoint fifo. when a new valid out packet is received on the endpoint bank 1, the rxoutb1 bit is set by the usb controller. this triggers an in terrupt if enabled. the firmware empties the bank 1 endpoint fifo before clearing the rxoutb1 bit. until the rxoutb1 bit has been cleared by the firmwar e, the usb controller will answe r a nak handshake for each out requests on the bank 1 endpoint fifo. the rxoutb0 and rxoutb1 bits are, alternat ively, set by the usb controller at each new valid packet receipt. the firmware has to clear one of these 2 bits after having read all the data fifo to allow a new valid packet to be stored in the corresponding bank. a nak handshake is sent by the usb contro ller only if the banks 0 and 1 has not been released by the firmware. out data0 (n bytes) ack host ufi c51 endpoint fifo bank 0 - read byte 1 rxoutb0 endpoint fifo bank 0 - read byte 2 endpoint fifo bank 0 - read byte n clear rxoutb0 out data1 (m bytes) ack rxoutb1 endpoint fifo bank 1 - read byte 1 endpoint fifo bank 1 - read byte 2 endpoint fifo bank 1 - read byte m clear rxoutb1 out data0 (p bytes) ack rxoutb0 endpoint fifo bank 0 - read byte 1 endpoint fifo bank 0 - read byte 2 endpoint fifo bank 0 - read byte p clear rxoutb0
112 at8xc51snd2c 4341e?mp3?06/05 if the host sends more bytes than support ed by the endpoint fifo, the overflow data won?t be stored, but the usb c ontroller will consider that the packet is valid if the crc is correct. bulk/interrupt in transactions in standard mode figure 71. bulk/interrupt in transactions in standard mode an endpoint should be first enabled and configured before being able to send bulk or interrupt packets. the firmware should fill the fifo with the dat a to be sent and set the txrdy bit in the uepstax register to allow the usb controlle r to send the data stored in fifo at the next in request concerning this endpoint. to send a zero length packet, the firmware should set the txrdy bit without writing any data into the endpoint fifo. until the txrdy bit has been set by the firmware, the usb controller will answer a nak handshake for each in requests. to cancel the sending of this packet, the firmware has to reset the txrdy bit. the packet stored in the endpoint fifo is then cleared and a new packet can be written and sent. when the in packet has been sent and acknowledged by the host, the txcmpl bit in the uepstax register is set by the usb c ontroller. this triggers a usb interrupt if enabled. the firmw are should clear the txcmpl bit be fore filling the endpoint fifo with new data. the firmware should never write more by tes than supported by the endpoint fifo. all usb retry mechanisms are automatically managed by the usb controller. in data0 (n bytes) ack host ufi c51 endpoint fifo write byte 1 in nak txcmpl endpoint fifo write byte 2 endpoint fifo write byte n set txrdy clear txcmpl endpoint fifo write byte 1
113 at8xc51snd2c 4341e?mp3?06/05 bulk/interrupt in transactions in ping-pong mode figure 72. bulk/interrupt in transact ions in ping-pong mode an endpoint should be first enabled and configured before being able to send bulk or interrupt packets. the firmware should fill the fifo bank 0 with the data to be sent and set the txrdy bit in the uepstax register to allo w the usb controller to send the data stored in fifo at the next in request concerning the endpo int. the fifo banks are automatically switched, and the firmware can immediatel y write into the endpoint fifo bank 1. when the in packet concerning the bank 0 has been sent and acknowledged by the host, the txcmpl bit is set by the usb co ntroller. this triggers a usb interrupt if enabled. the firmware should clear the txcmpl bit before filling the endpoint fifo bank 0 with new data. the fifo ba nks are then automatically switched. when the in packet concerning the bank 1 has been sent and acknowledged by the host, the txcmpl bit is set by the usb co ntroller. this triggers a usb interrupt if enabled. the firmware should clear the txcmpl bit before filling the endpoint fifo bank 1 with new data. the bank switch is performed by the usb cont roller each time the txrdy bit is set by the firmware. until the txrdy bit has been set by the firmware for an endpoint bank, the usb controller will answer a nak hands hake for each in requests concerning this bank. note that in the example above, the fi rmware clears the transmit complete bit (txcbulk-outmpl) before setting the transmit ready bit (txrdy). this is done in order to avoid the firmware to clear at the same time the txcmpl bit for for bank 0 and the bank 1. the firmware should never write more by tes than supported by the endpoint fifo. in data0 (n bytes) ack host ufi c51 endpoint fifo bank 0 - write byte 1 in nack txcmpl endpoint fifo bank 0 - write byte 2 endpoint fifo bank 0 - write byte n set txrdy endpoint fifo bank 1 - write byte 1 endpoint fifo bank 1 - write byte 2 endpoint fifo bank 1 - write byte m set txrdy in data1 (m bytes) ack endpoint fifo bank 0 - write byte 1 endpoint fifo bank 0 - write byte 2 endpoint fifo bank 0 - write byte p set txrdy clear txcmpl in data0 (p bytes) ack txcmpl clear txcmpl endpoint fifo bank 1 - write byte 1
114 at8xc51snd2c 4341e?mp3?06/05 control transactions setup stage the dir bit in the uepstax re gister should be at 0. receiving setup packets is the same as re ceiving bulk out packets, except that the rxsetup bit in the uepstax register is set by the usb controller instead of the rxoutb0 bit to indicate that an out packet with a setup pid has been received on the control endpoint. when the rxse tup bit has been set, all th e other bits of the uep- stax register are cleared and an interrupt is triggered if enabled. the firmware has to read the setup request stored in the control endpoint fifo before clearing the rxsetup bit to free the en dpoint fifo for the next transaction. data stage: control endpoint direction the data stage management is similar to bulk management. a control endpoint is managed by the usb controller as a full-duplex endpoint: in and out. all other endpoint types are managed as half-duplex endpoint: in or out. the firmware has to specify the control endpoint di rection for the data stage using the dir bit in the uepstax register. ? if the data stage consists of ins, the fi rmware has to set the dir bit in the uepstax register before writing into the fifo and sending the data by setting to 1 the txrdy bit in the uepstax register. the in trans action is complete when the txcmpl has been set by the hardware. the firmware should clear the txcmpl bit before any other transaction. ? if the data stage consists of outs, the fi rmware has to leave the dir bit at 0. the rxoutb0 bit is set by hardware when a new valid packet has been received on the endpoint. the firmware must read the data stored into the fifo and then clear the rxoutb0 bit to reset the fifo and to allow the next transaction. to send a stall handshake, see ?stall handshake? on page 117. status stage the dir bit in the uepstax register should be reset at 0 for in and out status stage. the status stage management is similar to bulk management. ? for a control write transaction or a no-data control transaction, the status stage consists of a in zero length packet (s ee ?bulk/interrupt in transactions in standard mode? on page 112). to send a stall handshake, see ?stall handshake? on page 117. ? for a control read transaction, the status stage consists of a out zero length packet (see ?bulk/interrupt out transactions in standard mode? on page 110).
115 at8xc51snd2c 4341e?mp3?06/05 isochronous transactions isochronous out transactions in standard mode an endpoint should be first enabled and conf igured before being able to receive isochro- nous packets. when an out packet is received on an en dpoint, the rxoutb0 bit is set by the usb controller. this triggers an interrupt if enabled. the firmware has to select the corre bulk-outsponding endpoint, store the numbe r of data bytes by reading the ubyctx register. if the received packet is a zlp (zero length packet), the ubyctx register value is equal to 0 and no data has to be read. the stlcrc bit in the uepstax register is set by the usb controller if the packet stored in fifo has a corrupted crc. this bit is update d after each new packet receipt. when all the endpoint fifo bytes have been read, the firmware should clear the rxoutb0 bit to allow the usb controller to store the next out packet data into the endpoint fifo. until the rxou tb0 bit has been cleared by the firmware, the data sent by the host at each ou t transaction will be lost. if the rxoutb0 bit is cleared while the host is sending data, the usb controller will store only the remaining bytes into the fifo. if the host sends more bytes than support ed by the endpoint fifo, the overflow data won?t be stored, but the usb c ontroller will consider that the packet is valid if the crc is correct. isochronous out transactions in ping-pong mode an endpoint should be first enabled and conf igured before being able to receive isochro- nous packets. when a out packet is received on the endpoi nt bank 0, the rxoutb0 bit is set by the usb controller. this triggers an interrupt if enabled. the firmware has to select the cor- responding endpoint, store the number of da ta bytes by reading the ubyctx register. if the received packet is a zlp (zero length pa cket), the ubyctx register value is equal to 0 and no data has to be read. the stlcrc bit in the uepstax register is set by the usb controller if the packet stored in fifo has a corrupted crc. this bit is update d after each new packet receipt. when all the endpoint fifo bytes have been read, the firmware should clear the rxoub0 bit to allow the usb controller to store the next out packet data into the end- point fifo bank 0. this action switches t he endpoint bank 0 and 1. until the rxoutb0 bit has been cleared by the firmware, the data sent by the host on the bank 0 endpoint fifo will be lost. if the rxoutb0 bit is cleared while the host is sending data on the endpoint bank 0, the usb controller will store only the remaining bytes into the fifo. when a new out packet is received on the endpoint bank 1, the rxoutb1 bit is set by the usb controller. this triggers an interrupt if enabled. the firmware empties the bank 1 endpoint fifo before clearing the rxoutb1 bit. until the rxoutb1 bit has been cleared by the firmware, the da ta sent by the host on the bank 1 endpoint fifo will be lost. the rxoutb0 and rxoutb1 bits are alternat ively set by the usb controller at each new packet receipt. the firmware has to clear one of these 2 bits after having read all the data fifo to allow a new packet to be stored in the corresponding bank.
116 at8xc51snd2c 4341e?mp3?06/05 if the host sends more bytes than support ed by the endpoint fifo, the overflow data won?t be stored, but the usb c ontroller will consider that the packet is valid if the crc is correct. isochronous in transactions in standard mode an endpoint should be first enabled and configured before being able to send isochro- nous packets. the firmware should fill the fifo with the dat a to be sent and set the txrdy bit in the uepstax register to allow the usb controlle r to send the data stored in fifo at the next in request concerning this endpoint. if the txrdy bit is not set wh en the in request occurs, no thing will be sent by the usb controller. when the in packet has been sent, the txcmpl bit in the uepstax register is set by the usb controller. this triggers a usb interrupt if enabled. the firmware should clear the txcmpl bit before filling the endpoint fi fo with new data. the firmware should never write more by tes than supported by the endpoint fifo isochronous in transactions in ping-pong mode an endpoint should be first enabled and configured before being able to send isochro- nous packets. the firmware should fill the fifo bank 0 with the data to be sent and set the txrdy bit in the uepstax register to allo w the usb controller to send the data stored in fifo at the next in request concerning the endpo int. the fifo banks are automatically switched, and the firmware can immediatel y write into the endpoint fifo bank 1. if the txrdy bit is not set wh en the in request occurs, no thing will be sent by the usb controller. when the in packet concerning the bank 0 has been sent, the txcmpl bit is set by the usb controller. this triggers a usb interrupt if enabled. the firmware should clear the txcmpl bit before filling the endpoint fifo bank 0 with new data. the fifo banks are then automatically switched. when the in packet concerning the bank 1 has been sent, the txcmpl bit is set by the usb controller. this triggers a usb interrupt if enabled. the firmware should clear the txcmpl bit before f illing the endpoint fifo bank 1 with new data. the bank switch is performed by the usb cont roller each time the txrdy bit is set by the firmware. until the txrdy bit has been set by the firmware for an endpoint bank, the usb controller won?t send anything at each in requests concerning this bank. the firmware should never write more by tes than supported by the endpoint fifo.
117 at8xc51snd2c 4341e?mp3?06/05 miscellaneous usb reset the eorint bit in the usbint register is set by hardware when a end of reset has been detected on the usb bus. this triggers a usb interrupt if enabled. the usb con- troller is still enabled, but all the usb registers are rese t by hardware. the firmware should clear the eorint bit to a llow the next usb reset detection. stall handshake this function is only available for control, bulk, and interrupt endpoints. the firmware has to set the stallrq bit in the uepstax register to send a stall handshake at the next request of the host on the endpoint selected with the uepnum register. the rxsetup, txrdy, txcmpl, rx outb0 and rxoutb1 bits must be first resseted to 0. the bit stlcrc is set at 1 by the usb controller when a stall has been sent. this triggers an interrupt if enabled. the firmware should clear the stallrq and stlcrc bits after each stall sent. the stallrq bit is cleared automatically by hardware when a valid setup pid is received on a control type endpoint. important note: when a clear halt feature occurs for an endpoint, the firmware should reset this endpoint using the ueprst resgister in order to reset the data toggle management. start of frame detection the sofint bit in the usbint register is set when the us b controller detects a start of frame pid. this triggers an interrupt if enabled. the firmware should clear the sofint bit to allow the next start of frame detection. frame number when receiving a start of frame, the fr ame number is automatically stored in the ufnuml and ufnumh registers. the crcok and crcerr bits indicate if the crc of the last start of frame is valid (crcok set at 1) or corrupted (crcerr set at 1). the ufnuml and ufnumh registers are automatically updated when receiving a new start of frame. data toggle bit the data toggle bit is set by hardware when a data0 packet is received and accepted by the usb controller and cleared by hardware when a data1 packet is received and accepted by the usb controller. this bit is reset when the firmware resets the endpoint fifo using the ueprst register. for control endpoints, each setup transacti on starts with a data0 and data toggling is then used as for bulk endpoints until the end of the data stage (for a control write transfer). the status stage completes the data transfer with a data1 (for a control read transfer). for isochronous endpoints, the device fi rmware should ignore the data-toggle.
118 at8xc51snd2c 4341e?mp3?06/05 suspend/resume management suspend the suspend state can be dete cted by the usb controller if all the clocks are enabled and if the usb controller is enabled. the bit spint is set by hardware when an idle state is detected for more than 3 ms. this triggers a usb interrupt if enabled. in order to reduce current consumption, th e firmware can put the usb pad in idle mode, stop the clocks and put the c51 in idle or power-down mode. the resume detection is still active. the usb pad is put in idle mode when the firmware clear the spint bit. in order to avoid a new suspend detection 3ms later, t he firmware has to disable the usb clock input using the suspclk bit in the usbcon register. the usb pad automatically exits of idle mode when a wake-up event is detected. the stop of the 48 mhz clock from the pll should be done in the following order: 1. disable of the 48 mhz clock input of th e usb controller by setting to 1 the sus- pclk bit in the usbcon register. 2. disable the pll by clearing the pllen bit in the pllcon register. resume when the usb controller is in suspend state, the resume detection is active even if all the clocks are disabled and if the c51 is in idle or power-down mode. the wupcpu bit is set by hardware when a non-idle state occurs on the usb bus. this triggers an inter- rupt if enabled. this interrupt wakes up the cpu from its idle or power-down state and the interrupt function is th en executed. the firmware will first enable th e 48 mhz gener- ation and then reset to 0 the suspclk bit in the usbcon register if needed. the firmware has to clear the spint bit in the usbint register before any other usb operation in order to wake up the usb controller from its suspend mode. the usb controller is then re-activated. figure 73. example of a suspend/resume management usb controller init detection of a suspend state spint set suspclk disable pll microcontroller in power-down detection of a resume state wupcpu enable pll clear suspclk clear wupcpu bit clear spint
119 at8xc51snd2c 4341e?mp3?06/05 upstream resume a usb device can be allowed by the host to send an upstream resume for remote wake-up purpose. when the usb controller receives the set_feature request: device_remote_wakeup, the firmware sh ould set to 1 the rmwupe bit in the usbcon register to enable this functionalit y. rmwupe value should be 0 in the other cases. if the device is in suspend mode, the usb controller can s end an upstr eam resume by clearing first the spint bit in the usbint re gister and by setting then to 1 the sdrm- wup bit in the usbcon register. the usb c ontroller sets to 1 the uprsm bit in the usbcon register. all clocks must be enabled first. the remote wake is sent only if the usb bus was in suspend state for at leas t 5ms. when the upstream resume is com- pleted, the uprsm bit is reset to 0 by hardware. the firmware should then clear the sdrmwup bit. figure 74. example of remote wakeup management usb controller init detection of a suspend state spint set rmwupe suspend management enable clocks upstream resume sent uprsm clear spint set sdmwup clear sdrmwup set_feature: device_remote_wakeup need usb resume uprsm = 1
120 at8xc51snd2c 4341e?mp3?06/05 usb interrupt system interrupt system priorities figure 75. usb interrupt control system table 1. priority levels usb interrupt control system as shown in figure 76, many events can produce a usb interrupt: ? txcmpl: transmitted in data (table 127 on page 126). this bit is set by hardware when the host accept a in packet. ? rxoutb0: received out data bank 0 (table 127 on page 126). this bit is set by hardware when an out packet is accepted by the endpoint and stored in bank 0. ? rxoutb1: received out data bank 1 (only for ping-pong endpoints) (table 127 on page 126). this bit is set by hardware when an out packet is accepted by the endpoint and stored in bank 1. ? rxsetup: received setup (table 127 on page 126). this bit is set by hardware when an setup packet is accepted by the endpoint. ? stlcrc: stalled (only for control, bulk and interrupt endpoints) (table 127 on page 126). this bit is set by hardware w hen a stall handshake has been sent as requested by stallrq, and is reset by hardware when a setup packet is received. ? sofint: start of frame interrupt (table 123 on page 123). this bit is set by hardware when a usb start of frame packet has been received. ? wupcpu: wake-up cpu interrupt (table 123 on page 123). this bit is set by hardware when a usb resume is detected on the usb bus, after a suspend state. ? spint: suspend interrupt (table 123 on page 123). this bit is set by hardware when a usb suspend is detected on the usb bus. eusb ie1.6 ea ie0.7 usb controller iph/l interrupt enable lowest priority interrupts priority enable 00 01 10 11 d+ d- iphusb iplusb usb priority level 0 0 0..................lowest 01 1 10 2 1 1 3..................highest
121 at8xc51snd2c 4341e?mp3?06/05 figure 76. usb interrupt control block diagram txcmp uepstax.0 rxoutb0 uepstax.1 rxsetup uepstax.2 stlcrc uepstax.3 epxie uepien.x epxint uepint.x sofint usbint.3 esofint usbien.3 spint usbint.0 espint usbien.0 eusb ie1.6 endpoint x (x = 0..2) eorint usbint.4 wupcpu usbint.5 ewupcpu usbien.5 rxoutb1 uepstax.6 eeorint usbien.4 nakout uepconx.5 nakin uepconx.4 nakien uepconx.6
122 at8xc51snd2c 4341e?mp3?06/05 registers table 121. usbcon register usbcon (s:bch) ? usb global control register reset value = 0000 0000b 76543210 usbe suspclk sdrmwup - uprsm rmwupe confg fadden bit number bit mnemonic description 7 usbe usb enable bit set this bit to enable the usb controller. clear this bit to disable and reset t he usb controller, to disable the usb transceiver an to disable the usb controllor clock inputs. 6suspclk suspend usb clock bit set to disable the 48 mhz clock input (resume detection is still active). clear to enable the 48 mhz clock input. 5 sdrmwup send remote wake-up bit set to force an external interrupt on the usb controller for remote wake up purpose. an upstream resume is send only if the bit rmwupe is set, all usb clocks are enabled and the usb bus was in suspend state for at least 5 ms. see uprsm below. cleared by software. 4- reserved the value read from this bit is always 0. do not set this bit. 3 uprsm upstream resume bit (read only) set by hardware when sdrmwup has been set and if rmwupe is enabled. cleared by hardware after the upstream resume has been sent. 2rmwupe remote wake-up enable bit set to enabled request an upstream resume signaling to the host. clear after the upstream resume has been indicated by rsminpr. note: do not set this bit if the host has not set the device_remote_wakeup feature for the device. 1confg configuration bit this bit should be set by the device firmware after a set_configuration request with a non-zero value has been correctly processed. it should be cleared by the device firmware when a set_configuration request with a zero value is received . it is cleared by hardware on hardware reset or when an usb reset is detected on the bus (se0 state for at least 32 full speed bit times: typically 2.7 p s). 0fadden function address enable bit this bit should be set by the device firm ware after a successful status phase of a set_address transaction. it should not be cleared afterwards by the device firmware. it is cleared by hardware on hardware reset or when an usb reset is received (see above). when this bit is cleared, the def ault function address is used (0).
123 at8xc51snd2c 4341e?mp3?06/05 table 122. usbaddr register usbaddr (s:c6h) ? usb address register reset value = 0000 0000b table 123. usbint register usbint (s:bdh) ? usb gl obal interrupt register reset value = 0000 0000b 76543210 fen uadd6 uadd5 uadd4 uadd3 uadd2 uadd1 uadd0 bit number bit mnemonic description 7fen function enable bit set to enable the function. the device firm ware should set this bit after it has received a usb reset and participate in t he following configuration process with the default address (fen is reset to 0). cleared by hardware at power-up, should not be cleared by the device firmware once set. 6 - 0 uadd6:0 usb address bits this field contains the default address (0) after power-up or usb bus reset. it should be written with the value set by a set_address request received by the device firmware. 76543210 - - wupcpu eorint sofint - - spint bit number bit mnemonic description 7 - 6 - reserved the value read from these bits is always 0. do not set these bits. 5 wupcpu wake up cpu interrupt flag set by hardware when the usb controller is in suspend state and is re- activated by a non-idle signal from usb line (not by an upstream resume). this triggers a usb interrupt when ewupcpu is set in the usbien. cleared by software after re-enabling all usb clocks. 4eorint end of reset interrupt flag set by hardware when a end of reset has been detected by the usb controller. this triggers a usb interrupt when eeorint is set in usbien. cleared by software. 3sofint start of frame interrupt flag set by hardware when an usb start of frame packet (sof) has been properly received. this triggers a usb interrupt when esofint is set in usbien. cleared by software. 2 - 1 - reserved the value read from these bits is always 0. do not set these bits. 0 spint suspend interrupt flag set by hardware when a usb suspend (idle bus for three frame periods: a j state for 3 ms) is detected. this tri ggers a usb interrupt when espint is set in usbien. cleared by software.
124 at8xc51snd2c 4341e?mp3?06/05 table 124. usbien register usbien (s:beh) ? usb global interrupt enable register reset value = 0001 0000b table 125. uepnum register uepnum (s:c7h) ? usb endpoint number reset value = 0000 0000b 76543210 - - ewupcpu eeorint esofint - - espint bit number bit mnemonic description 7 - 6 - reserved the value read from these bits is always 0. do not set these bits. 5 ewupcpu wake up cpu interrupt enable bit set to enable the wake up cpu interrupt. clear to disable the wake up cpu interrupt. 4eeofint end of reset interrupt enable bit set to enable the end of reset interrupt. this bit is set after reset. clear to disable end of reset interrupt. 3esofint start of frame interrupt enable bit set to enable the sof interrupt. clear to disable the sof interrupt. 2 - 1 - reserved the value read from these bits is always 0. do not set these bits. 0 espint suspend interrupt enable bit set to enable suspend interrupt. clear to disable suspend interrupt. 76543210 ------epnum1epnum0 bit number bit mnemonic description 7 - 2 - reserved the value read from these bits is always 0. do not set these bits. 1 - 0 epnum1:0 endpoint number bits set this field with the number of the endpoint which should be accessed when reading or writing to registers uepst ax, uepdatx, ubyctx or uepconx.
125 at8xc51snd2c 4341e?mp3?06/05 table 126. uepconx register uepconx (s:d4h) ? usb endpoint x contro l register (x = epnum set in uepnum) reset value = 1000 0000b 76543210 epen nakien nakout nakin dtgl epdir eptype1 eptype0 bit number bit mnemonic description 7 epen endpoint enable bit set to enable the endpoint according to the device configuration. endpoint 0 should always be enabled after a hardware or usb bus reset and participate in the device configuration. clear to disable the endpoint accord ing to the device configuration. 6nakien nak interrupt enable set this bit to enable nak in or nak out interrupt. clear this bit to disable nak in or nak out interrupt. 5 nakout nak out received this bit is set by hardware when an nak handshake has been sent in response of a out request from the host. this triggers a usb interrupt when nakien is set. this bit should be cleared by software. 4 nakin nak in received this bit is set by hardware when an nak handshake has been sent in response of a in request from the host. this triggers a usb interrupt when nakien is set. this bit should be cleared by software. 3dtgl data toggle status bit (read-only) set by hardware when a data1 packet is received. cleared by hardware when a data0 packet is received. 2 epdir endpoint direction bit set to configure in direction for bu lk, interrupt and isochronous endpoints. clear to configure out direction for bulk, interrupt and isochronous endpoints. this bit has no effect for control endpoints. 1-0 eptype1:0 endpoint type bits set this field according to the endpoint configuration (endpoint 0 should always be configured as control): 00 control endpoint 01 isochronous endpoint 10 bulk endpoint 11 interrupt endpoint
126 at8xc51snd2c 4341e?mp3?06/05 table 127. uepstax register uepstax (s:ceh) ? usb endpoint x status and control register (x = epnum set in uepnum ) 76543210 dir rxoutb1 stallrq txrdy st lcrc rxsetup rxoutb0 txcmp bit number bit mnemonic description 7dir control endpoint direction bit this bit is relevant only if the endpoint is configured in control type. set for the data stage. clear otherwise. note: this bit should be configured on rxsetup interrupt before any other bit is changed. this also determines the status phase (in for a control write and out for a control read). this bit should be cleared for status stage of a control out transaction. 6 rxoutb1 received out data bank 1 for endpoints 1 and 2 (ping-pong mode) this bit is set by hardware after a new packet has been stored in the endpoint fifo data bank 1 (only in ping-pong mode). then, the endpoint interrupt is triggered if enabled and all the following out packets to the endpoint bank 1 are rejected (nak?ed) until this bit has been cleared, excepted for isochronous endpoints. this bit should be cleared by the devi ce firmware after reading the out data from the endpoint fifo.
127 at8xc51snd2c 4341e?mp3?06/05 reset value = 0000 0000b 5 stallrq stall handshake request bit set to send a stall answer to the host for the next handshake. clear otherwise. 4 txrdy tx packet ready control bit set after a packet has been written into the endpoint fifo for in data transfers. data should be written into the endpoint fifo only after this bit has been cleared. set this bit without writing data to the endpoint fifo to send a zero length packet, which is generally recommended and may be required to terminate a transfer when the length of the last data packet is equal to maxpacketsize (e.g. for control read transfers). cleared by hardware, as soon as th e packet has been sent for isochronous endpoints, or after the host has acknowledged the packet for control, bulk and interrupt endpoints. 3stlcrc stall sent interrupt flag/crc error interrupt flag for control, bulk and interrupt endpoints: set by hardware after a stall handshake has been sent as requested by stallrq. then, the endpoint interrupt is triggered if enabled in uepien. cleared by hardware when a setup packet is received (see rxsetup). for isochronous endpoints: set by hardware if the last data received is corrupted (crc error on data). then, the endpoint interrupt is triggered if enabled in uepien. cleared by hardware when a non corrupted data is received. 2 rxsetup received setup interrupt flag set by hardware when a valid setup packet has been received from the host. then, all the other bits of the register are cleared by hardware and the endpoint interrupt is triggered if enabled in uepien. clear by software after reading the setup data from the endpoint fifo. 1 rxoutb0 received out data bank 0 (see also rxoutb1 bit for ping-pong endpoints) this bit is set by hardware after a new packet has been stored in the endpoint fifo data bank 0. then, the endpoint interrupt is triggered if enabled and all the following out packets to the endpoint bank 0 are rejected (nak?ed) until this bit has been cleared, excepted for isochronous endpoints. however, for control endpoints, an early setup transaction may overwrite the content of the endpoint fifo, even if its data packet is received while this bit is set. this bit should be cleared by the devi ce firmware after reading the out data from the endpoint fifo. 0txcmp transmitted in data complete interrupt flag set by hardware after an in pack et has been transmitted for isochronous endpoints and after it has been accepted (ack?ed) by the host for control, bulk and interrupt endpoints. then, the endpoint interrupt is triggered if enabled in uepien. clear by software before setting again txrdy. bit number bit mnemonic description
128 at8xc51snd2c 4341e?mp3?06/05 table 128. ueprst register ueprst (s:d5h) ? usb endp oint fifo reset register reset value = 0000 0000b table 129. uepien register uepien (s:c2h) ? usb endpoint interrupt enable register reset value = 0000 0000b 76543210 -----ep2rstep1rstep0rst bit number bit mnemonic description 7 - 3 - reserved the value read from these bits is always 0. do not set these bits. 2 ep2rst endpoint 2 fifo reset set and clear to reset the endpoint 2 fifo prior to any other operation, upon hardware reset or when an usb bus reset has been received. 1 ep1rst endpoint 1 fifo reset set and clear to reset the endpoint 1 fifo prior to any other operation, upon hardware reset or when an usb bus reset has been received. 0 ep0rst endpoint 0 fifo reset set and clear to reset the endpoint 0 fifo prior to any other operation, upon hardware reset or when an usb bus reset has been received. 76543210 -----ep2inteep1inteep0inte bit number bit mnemonic description 7 - 3 - reserved the value read from these bits is always 0. do not set these bits. 2 ep2inte endpoint 2 interrupt enable bit set to enable the interrupts for endpoint 2. clear this bit to disable the interrupts for endpoint 2. 1 ep1inte endpoint 1 interrupt enable bit set to enable the interrupts for the endpoint 1. clear to disable the interrupts for the endpoint 1. 0 ep0inte endpoint 0 interrupt enable bit set to enable the interrupts for the endpoint 0. clear to disable the interrupts for the endpoint 0.
129 at8xc51snd2c 4341e?mp3?06/05 table 130. uepint register uepint (s:f8h read-only) ? usb endpoint interrupt register reset value = 0000 0000b table 131. uepdatx register uepdatx (s:cfh) ? usb endpoint x fifo data register (x = epnum set in uepnum) reset value = xxh 76543210 -----ep2intep1intep0int bit number bit mnemonic description 7 - 3 - reserved the value read from these bits is always 0. do not set these bits. 2 ep2int endpoint 2 interrupt flag this bit is set by hardware when an endpoint interrupt source has been detected on the endpoint 2. the endpoint interrupt sources are in the uepstax register and can be: txcmp, rxoutb0, rxoutb1, rxsetup or stlcrc. a usb interrupt is triggered when the ep2ie bit in the uepien register is set. this bit is cleared by hardware when all the endpoint interrupt sources are cleared. 1 ep1int endpoint 1 interrupt flag this bit is set by hardware when an endpoint interrupt source has been detected on the endpoint 1. the endpoint interrupt sources are in the uepstax register and can be: txcmp, rxoutb0, rxoutb1, rxsetup or stlcrc. a usb interrupt is triggered when the ep1ie bit in the uepien register is set. this bit is cleared by hardware when all the endpoint interrupt sources are cleared. 0 ep0int endpoint 0 interrupt flag this bit is set by hardware when an endpoint interrupt source has been detected on the endpoint 0. the endpoint interrupt sources are in the uepstax register and can be: txcmp, rxoutb0, rxoutb1, rxsetup or stlcrc. a usb interrupt is triggered when the ep0ie bit in the uepien register is set. this bit is cleared by hardware when all the endpoint interrupt sources are cleared. 76543210 fdat7 fdat6 fdat5 fdat4 fdat3 fdat2 fdat1 fdat0 bit number bit mnemonic description 7 - 0 fdat7:0 endpoint x fifo data data byte to be written to fifo or data byte to be read from the fifo, for the endpoint x (see epnum).
130 at8xc51snd2c 4341e?mp3?06/05 table 132. ubyctx register ubyctx (s:e2h) ? usb endpoint x byte co unt register (x = epnum set in uepnum) reset value = 0000 0000b table 133. ufnuml register ufnuml (s:bah, read-only) ? usb frame number low register reset value = 00h 76543210 - byct6 byct5 byct4 byct3 byct2 byct1 byct0 bit number bit mnemonic description 7- reserved the value read from this bits is always 0. do not set this bit. 6 - 0 byct7:0 byte count byte count of a received data packet. this byte count is equal to the number of data bytes received after the data pid. 76543210 fnum7 fnum6 fnum5 fnum4 fnum3 fnum2 fnum1 fnum0 bit number bit mnemonic description 7 - 0 fnum7:0 frame number lower 8 bits of the 11-bit frame number.
131 at8xc51snd2c 4341e?mp3?06/05 table 134. ufnumh register ufnumh (s:bbh, read-only) ? usb frame number high register reset value = 00h table 135. usbclk register usbclk (s:eah) ? usb clock divider register reset value = 0000 0000b 76543210 - - crcok crcerr - fnum10 fnum9 fnum8 bit number bit mnemonic description 7 - 3 - reserved the value read from these bits is always 0. do not set these bits. 5 crcok frame number crc ok bit set by hardware after a non corrupted frame number in start of frame packet is received. updated after every start of frame packet reception. note: the start of frame interrupt is generated just after the pid receipt. 4 crcerr frame number crc error bit set by hardware after a corrupted frame number in start of frame packet is received. updated after every start of frame packet reception. note: the start of frame interrupt is generated just after the pid receipt. 3- reserved the value read from this bits is always 0. do not set this bit. 2-0 fnum10:8 frame number upper 3 bits of the 11-bit frame number. it is provided in the last received sof packet. fnum does not change if a corrupted sof is received. 76543210 ------usbcd1usbcd0 bit number bit mnemonic description 7 - 2 - reserved the value read from these bits is always 0. do not set these bits. 1 - 0 usbcd1:0 usb controller clock divider 2-bit divider for usb c ontroller clock generation.
132 at8xc51snd2c 4341e?mp3?06/05 ide/atapi interface the at8xc51snd2c provides an ide/atapi interface allowing connection of devices such as cd-rom reader, compac tflash cards, hard disk drive, etc. it consists of a 16- bit data transfer (read or write) between the at8xc51snd2c and the ide device. description the ide interface mode is enabled by setting the ext16 bit in auxr (see figure 30, page 29). as soon as this bit is set, all movx instructions read or write are done in a 16- bit mode compare to the standard 8-bit mode. p0 carries the low order multiplexed address and data bus (a7:0, d7:0) while p2 carries the high order multiplexed address and data bus (a15:8, d15:8). when writing dat a in ide mode, the acc contains d7:0 data (as in 8-bit mode) while dat16h register (see table 137) contains d15:8 data. when reading data in ide mode, d7:0 data is returned in acc while d15:8 data is returned in dat16h. figure 77 shows the ide read bus cycle while figure 78 shows the ide write bus cycle. for simplicity, these figures de pict the bus cycle waveforms in idealized form and do not provide precise timing information. for ide bus cycle timing parameters refer to the section ?ac characteristics?. ide cycle takes 6 cpu clock periods which is equivalent to 12 oscillator clock periods in standard mode or 6 oscillator clock periods in x2 mode. for further information on x2 mode, refer to the section ?x2 feature?, page 12. slow ide devices can be accessed by stretching the read and write cycles. this is done using the m0 bit in auxr. setting this bit changes t he width of the rd and wr signals from 3 to 15 cpu clock periods. figure 77. ide read waveforms notes: 1. rd signal may be stretched using m0 bit in auxr register. 2. when executing movx @ri instruction, p2 outputs sfr content. 3. when executing movx @dptr instruction, if dphdis is set (page access mode), p2 outputs sfr content instead of dph. ale p0 p2 rd (1) dpl or ri d7:0 p2 cpu clock dph or p2 (2),(3) d15:8 p2
133 at8xc51snd2c 4341e?mp3?06/05 figure 78. ide write waveforms notes: 1. wr signal may be stretched using m0 bit in auxr register. 2. when executing movx @ri instruction, p2 outputs sfr content. 3. when executing movx @dptr instruction, if dphdis is set (page access mode), p2 outputs sfr content instead of dph. ide device connection figure 79 and figure 80 show 2 examples on how to interface up to 2 ide devices to the at8xc51snd2c. in both examples p0 carries ide low order data bits d7:0, p2 carries ide high order data bits d15:8, while rd and wr signals are respectively connected to the ide nior and niow signals. other ide control signals are generated by the exter- nal address latch outputs in the first example while they are generated by some port i/os in the second one. using an external latch will achieve higher transfer rate. figure 79. ide device connection example 1 figure 80. ide device connection example 2 ale p0 p2 wr (1) dpl or ri d7:0 p2 cpu clock dph or p2 (2),(3) d15:8 p2 p2 p0 d15-8 a2:0 ale niow nior rd wr d7:0 ncs1:0 nreset d15-8 a2:0 niow nior d7:0 ncs1:0 nreset latch ide device 0 ide device 1 at8xc51snd2c px.y p2/a15:8 p0/ad7:0 d15-8 a2:0 p4.5 niow nior rd wr d7:0 ncs1:0 nreset d15-8 a2:0 niow nior d7:0 ncs1:0 nreset p4.2:0 p4.4:3 ide device 0 at8xc51snd2c ide device 1
134 at8xc51snd2c 4341e?mp3?06/05 table 136. external data memory interface signals registers table 137. dat16h register dat16h (s:f9h) ? data 16 high order byte reset value =xxxx xxxxb signal name type description alternate function a15:8 i/o address lines upper address lines for the external bus. multiplexed higher address and data lines for the ide interface. p2.7:0 ad7:0 i/o address/data lines multiplexed lower address and data lines for the ide interface. p0.7:0 ale o address latch enable ale signals indicates that valid addre ss information is available on lines ad7:0. - rd o read read signal output to external data memory. p3.7 wr o write write signal output to external memory. p3.6 76543210 d15 d14 d13 d12 d11 d10 d9 d8 bit number bit mnemonic description 7 - 0 d15:8 data 16 high order byte when ext16 bit is set, dat16h is set by software with the high order data byte prior any movx write instruction. when ext16 bit is set, dat16h contains the high order data byte after any movx read instruction.
135 at8xc51snd2c 4341e?mp3?06/05 multimedia card controller the at8xc51snd2c implements a multimedi a card (mmc) controller. the mmc is used to store mp3 encoded audio files in removable flash memory cards that can be easily plugged or removed from the application. card concept the basic multimedia card concept is based on transferring data via a minimum number of signals. card signals the communication signals are: ? clk: with each cycle of this signal a one bit transfer on the command and data lines is done. the frequency may vary from zero to the maximum clock frequency. ? cmd: is a bi-directional command channel used for card initialization and data transfer commands. the cmd signal has 2 operation modes: open-drain for initialization mode and push-pull for fast command transfer. commands are sent from the multimedia card bus master to the card and responses from the cards to the host. ? dat: is a bi-directional data channel. the dat signal operates in push-pull mode. only one card or the host is driving this signal at a time. card registers within the card interface fi ve registers are defined: o cr, cid, csd, rca and dsr. these can be accessed only by the corresponding commands. the 32-bit operation conditions register (ocr) stores the v dd voltage profile of the card. the register is optional and can be read only. the 128-bit wide cid register carries the ca rd identification information (card id) used during the card identification procedure. the 128-bit wide card-specific data register (csd) provides information on how to access the card contents. the csd defines the data format, error correction type, maxi- mum data access time, data transfer speed, and whether the dsr register can be used. the 16-bit relative card address register (rca) carries the card address assigned by the host during the card identification. this address is used for the addressed host-card communication after the card identification procedure. the 16-bit driver stage register (dsr) can be optionally used to improve the bus per- formance for extended operating conditions (depending on parameters like bus length, transfer rate or number of cards). bus concept the multimedia card bus is designed to c onnect either solid-state mass-storage mem- ory or i/o-devices in a card format to multimedia applications. the bus implementation allows the coverage of application fields from low-cost systems to systems with a fast data transfer rate. it is a single master bu s with a variable number of slaves. the multi- media card bus master is the bus controller and each slave is either a single mass storage card (with possibly different technolog ies such as rom, otp, flash etc.) or an i/o-card with its own contro lling unit (on card) to pe rform the data transfer. the multimedia card bus also includes power connections to supply the cards. the bus communication uses a special protoc ol (multimedia card bus protocol) which is applicable for all devices. therefore, the payload data transfer between the host and the cards can be bi-directional.
136 at8xc51snd2c 4341e?mp3?06/05 bus lines the multimedia card bus archit ecture requires all cards to be connected to the same set of lines. no card has an individual connection to the host or other devices, which reduces the connection costs of the multimedia card system. the bus lines can be divided into three groups: ? power supply: v ss1 and v ss2 , v dd ? used to supply the cards. ? data transfer: mcmd, mdat ? used for bi-directional communication. ? clock: mclk ? used to synchroniz e data transfer across the bus. bus protocol after a power-on reset, the host must initialize the cards by a special message-based multimedia card bus protocol. each message is represented by one of the following tokens: ? command: a command is a token which starts an operation. a command is transferred serially from the host to the card on the mcmd line. ? response: a response is a token which is sent from an addressed card (or all connected cards) to the host as an answer to a previously received command. it is transferred serially on the mcmd line. ? data: data can be transferred from the card to the host or vice-versa. data is transferred serially on the mdat line. card addressing is implemented using a se ssion address assigned during the initializa- tion phase, by the bus controller to all cu rrently connected cards. individual cards are identified by their cid number . this method requires that every card will have an unique cid number. to ensure uniqueness of cids the cid register contains 24 bits (mid and oid fields) which are defined by the mmca. every card manufacturers is required to apply for an unique mid (and optionally oid) number. multimedia card bus data transfers are composed of these tokens. one data transfer is a bus operation. there are different types of operations. addressed operations always contain a command and a response token. in addition, some operations have a data token, the others transfer their information directly within the command or response structure. in this case no data token is present in an operation. the bits on the mdat and the mcmd lines are transferred synchronous to the host clock. 2 types of data transfer commands are defined: ? sequential commands: these commands init iate a continuous data stream, they are terminated only when a stop command follows on the mcmd line. this mode reduces the command overhead to an absolute minimum. ? block-oriented commands: these commands send a data block succeeded by crc bits. both read and write operations a llow either single or multiple block transmission. a multiple block transmission is terminated when a stop command follows on the mcmd line sim ilarly to the stream read. figure 81 through figure 85 show the different types of operations, on these figures, grayed tokens are from host to card(s) while white tokens are from card(s) to host. figure 81. sequential read operation data stream command response mcmd mdat data stop operation data transfer operation command response stop command
137 at8xc51snd2c 4341e?mp3?06/05 figure 82. (multiple) block read operation as shown in figure 83 and figure 84 the data write operation uses a simple busy signal- ling of the write operation duration on the data line (mdat). figure 83. sequential write operation figure 84. multiple block write operation figure 85. no response and no data operation command token format as shown in figure 86, commands have a fixed code length of 48 bits. each command token is preceded by a start bit: a low le vel on mcmd line and succeeded by an end bit: a high level on mcmd line. the command content is preceded by a transmission bit: a high level on mcmd line for a command token (host to card) and succeeded by a 7 - bit crc so that transmission errors can be detected and the operation may be repeated. command content contains the command inde x and address information or parameters. figure 86. command token format data block mcmd mdat data stop operation block read operation crc multiple block read operation command response command response data block crc data block crc stop command data stream mcmd mdat data stop operation data transfer operation command response command response stop command busy mcmd mdat data stop operation block write operation multiple block write operation busy data block crc data block crc command response command response stop command status busy status command mcmd mdat no data operation no response operation command response 0 total length = 48 bits content crc 1 1
138 at8xc51snd2c 4341e?mp3?06/05 table 138. command token format response token format there are five types of response tokens (r 1 to r5). as shown in figure 87, responses have a code length of 48 bits or 136 bits. a response token is preceded by a start bit: a low level on mcmd line and succeeded by an end bit: a high level on mcmd line. the command content is preceded by a transmission bit: a low level on mcmd line for a response token (card to host) and succeeded (r1,r2,r4,r5) or not (r3) by a 7 - bit crc. response content contains mirrored command and status information (r1 response), cid register or csd register (r2 response), ocr register (r3 response), or rca regis- ter (r4 and r5 response). figure 87. response token format table 139. r1 response format (normal response) table 140. r2 response format (cid and csd registers) bit position 47 46 45:40 39:8 7:1 0 width (bits) 1163271 value ?0? ?1? - - - ?1? description start bit transmission bit command index argument crc7 end bit bit position 47 46 45:40 39:8 7:1 0 width (bits) 1 1 6327 1 value ?0? ?0? - - - ?1? description start bit transmission bit command index card status crc7 end bit bit position 135 134 [133:128] [127:1] 0 width (bits) 116321 value ?0? ?0? ?111111? - ?1? description start bit transmission bit reserved argument end bit 0 total length = 48 bits content crc 0 1 r1, r4, r5 0 total length = 136 bits content = cid or csd crc 0 1 r2 0 total length = 48 bits content 0 1 r3
139 at8xc51snd2c 4341e?mp3?06/05 table 141. r3 response format (ocr register) table 142. r4 response format (fast i/o) table 143. r5 response format data packet format there are 2 types of data packets: stream and block. as shown in figure 88, stream data packets have an indeterminate length while block packets have a fixed length depending on the block length. each data packe t is preceded by a start bit: a low level on mcmd line and succeeded by an end bit: a high level on mcmd line. due to the fact that there is no predefined end in stream packets, crc protection is not included in this case. the crc protection algorithm for bl ock data is a 16-b it ccitt polynomial. figure 88. data token format clock control the mmc bus clock signal can be used by the host to turn the cards into energy saving mode or to control the data flow (to avoid under-run or ov er-run conditions) on the bus. the host is allowed to lower the clock frequency or shut it down. there are a few restrictions the host must follow: ? the bus frequency can be changed at any ti me (under the restrictions of maximum data transfer frequency, defined by the cards, and the identification frequency defined by the spec ification document). ? it is an obvious requiremen t that the clock must be ru nning for the card to output data or response tokens. after the last multimedia card bus transaction, the host is bit position 47 46 [45:40] [39:8] [7:1] 0 width (bits) 11 63271 value ?0? ?0? ?111111? - ?1111111? ?1? description start bit transmission bit reserved ocr register reserved end bit bit position 47 46 [45:40] [39:8] [7:1] 0 width (bits) 11 63271 value ?0? ?0? ?100111? - - ?1? description start bit transmission bit command index argument crc7 end bit bit position 47 46 [45:40] [39:8] [7:1] 0 width (bits) 11 63271 value ?0? ?0? ?101000? - - ?1? description start bit transmission bit command index argument crc7 end bit 0 content 1 sequential data crc block data 0 content 1 block length
140 at8xc51snd2c 4341e?mp3?06/05 required, to provide 8 (eight) clock cycles for the card to complete the operation before shutting down the clock. following is a list of the various bus transactions: ? a command with no response. 8 clocks after the host command end bit. ? a command with response. 8 cloc ks after the card command end bit. ? a read data transaction. 8 clocks afte r the end bit of the last data block. ? a write data transaction. 8 clocks after the crc status token. ? the host is allowed to shut down the clo ck of a ?busy? card. t he card will complete the programming operation regardless of th e host clock. however, the host must provide a clock edge for the card to turn off its busy signal. without a clock edge the card (unless previously disconnected by a deselect command-cmd7) will force the mdat line down, forever. description the mmc controller interfaces to the c51 co re through the following eight special func- tion registers: mmcon0, mmcon1, mmcon2, the three mmc control registers (see table 145 to table 153); mmsta, the mmc status regist er (see table 148); mmint, the mmc inter- rupt register (see table 149); mmmsk, the mmc interrupt mask register (see table 150); mmcmd, the mmc command register (see table 151); mmdat, the mmc data register (see table 152); and mmclk, the mmc clock register (see table 153). as shown in figure 89, the mmc controller is divided in four blocks: the clock generator that handles the mclk (for mally the mmc clk) output to the card, the command line controller that handles the mcmd (formally the mmc cmd) line traffic to or from the card, the data line controller that handles th e mdat (formally the mmc dat) line traffic to or from the card, and the interrupt controller that handle s the mmc contro ller interrupt sources. these blocks are detailed in the following sections. figure 89. mmc controller block diagram clock generator the mmc clock is generated by division of the oscillator clock (f osc ) issued from the clock controller block as detaile d in section "oscillator", pa ge 12. the division factor is given by mmcd7:0 bits in mmclk register, a value of 0x00 stops the mmc clock. figure 90 shows the mmc clock generator and its output clock calculation formula. osc clock mcmd mclk 8 internal bus mdat command line clock mmc interrupt request generator controller data line controller interrupt controller
141 at8xc51snd2c 4341e?mp3?06/05 figure 90. mmc clock generator and symbol as soon as mmcen bit in mmcon2 is se t, the mmc controller receives its system clock. the mmc command and data clock is ge nerated on mclk output and sent to the command line and data line controllers. figu re 91 shows the mmc controller configura- tion flow. as exposed in section ?clock control?, page 139, mmcd7:0 bits can be used to dynam- ically increase or reduce the mmc clock. figure 91. configuration flow mmcd7:0 mmclk mmc clock mmcclk oscclk mmcd 1 + ----------------------------- = osc clock mmcen mmcon2.7 controller clock mmc clock mmc clock symbol mmc controller configuration configure mmc clock mmclk = xxh mmcen = 1 flowc = 0
142 at8xc51snd2c 4341e?mp3?06/05 command line controller as shown in figure 92, the command line controller is divided in 2 channels: the com- mand transmitter channel that handles the command transmission to the card through the mcmd line and the command receiver channel that handles the response reception from the card through the mcmd line. these channels are detailed in the following sections. figure 92. command line controller block diagram command transmitter for sending a command to the card, user must load the command index (1 byte) and argument (4 bytes) in the command trans mit fifo using the mmcmd register. before starting transmission by sett ing and clearing the cmden bit in mmcon1 register, user must first configure: ? respen bit in mmcon1 register to indica te whether a response is ex pected or not. ? rfmt bit in mmcon0 register to indi cate the response size expected. ? crcdis bit in mmcon0 register to indi cate whether the crc7 included in the response will be computed or not. in order to avoid crc error, crcdis may be set for response that do not include crc7. figure 93 summarizes the command transmission flow. as soon as command transmission is enabled, the cflck flag in mmsta is set indicat- ing that write to the fifo is locked. this mechanism is implemented to avoid command overrun. the end of the command transmission is signalled to you by the eoci flag in mmint register becoming set. this flag may generate an mmc interrupt request as detailed in section "interrupt", page 150. the end of the command transmission also resets the cflck flag. ctptr mmcon0.4 crptr mmcon0.5 mcmd cmden mmcon1.0 tx command line finished state machine data converter // -> serial 5-byte fifo mmcmd tx pointer rfmt mmcon0.1 crcdis mmcon0.0 respen mmcon1.1 data converter serial -> // rx pointer 17 - byte fifo mmcmd cflck mmsta.0 crc7 generator rx command line finished state machine crc7 and format checker crc7s mmsta.2 respfs mmsta.1 eoci mmint.5 eori mmint.6 command transmitter command receiver write read
143 at8xc51snd2c 4341e?mp3?06/05 user may abort command loading by setting and clearing the ctptr bit in mmcon0 register which resets the write pointer to the transmit fifo. figure 93. command transmission flow command receiver the end of the response reception is signalled to you by the eori flag in mmint regis- ter. this flag may generate an mmc interrupt request as detailed in section "interrupt", page 150. when this flag is set, 2 othe r flags in mmsta register: respfs and crc7s give a status on the response re ceived. respfs indicates if the response format is cor- rect or not: the size is the one expected (48 bits or 136 bits) and a valid end bit has been received, and crc7s indicates if the crc7 computation is correc t or not. these flags are cleared when a command is sent to t he card and updated when the response has been received. user may abort response reading by setting and clearing the crptr bit in mmcon0 register which resets the read pointer to the receive fifo. according to the mmc specification delay between a command and a response (for- mally n cr parameter) can not exceed 64 mmc clock periods. to avoid any locking of the mmc controller when card does not send its response (e.g. ph ysically removed from the bus), user must launch a time-out period to exit from such situation. in case of time- out user may reset the command controller and its internal state machine by setting and clearing the ccr bit in mmcon2 register. this time-out may be disarmed when receiving the response. command transmission load command in buffer mmcmd = index mmcmd = argument configure response respen = x rfmt = x crcdis = x transmit command cmden = 1 cmden = 0
144 at8xc51snd2c 4341e?mp3?06/05 data line controller the data line controller is based on a 16-byte fifo used both by the data transmitter channel and by the data receiver channel. figure 94. data line controller block diagram fifo implementation the 16-byte fifo is based on a dual 8-byte fifos managed using 2 pointers and four flags indicating the status full and empty of each fifo. pointers are not accessible to user but can be reset at any time by setting and clearing drptr and dtptr bits in mmcon0 register. resetting the pointers is equivalent to abort the writing or reading of data. f1ei and f2ei flags in mmint register si gnal when set that respectively fifo1 and fifo2 are empty. f1fi and f2fi flags in mmi nt register signal w hen set that respec- tively fifo1 and fifo2 are full. these flag s may generate an mmc interrupt request as detailed in sect ion ?interrupt?. data configuration before sending or receiving any data, the data line controller must be configured accord- ing to the type of the data transfer considered. this is achieved using the data format bit: dfmt in mmcon0 register. clearing dfmt bit enables the data stream format while setting dfmt bit enables the data block format. in data block format, user must also configure the single or multi-block mode by clearing or setting the mblock bit in mmcon0 register and the block length using blen3:0 bits in mmcon1 according to table 144. figure 95 summarizes the data modes configuration flows. table 144. block length programming mcbi mmint.1 datfs mmsta.3 crc16s mmsta.4 f2fi mmint.3 f2ei mmint.1 dfmt mmcon0.2 mblock mmcon0.3 datdir mmcon1.3 data converter // -> serial blen3:0 mmcon1.7:4 daten mmcon1.2 data line finished state machine data converter serial -> // dtptr mmcon0.6 drptr mmcon0.7 tx pointer rx pointer 8-byte fifo 1 8-byte fifo 2 16-byte fifo mmdat f1ei mmint.0 crc16 and format checker f1fi mmint.2 eofi mmint.4 cbusy mmsta.5 crc16 generator mdat blen3:0 block length (byte) blen = 0000 to 1011 length = 2 blen : 1 to 2048 > 1011 reserved: do not program blen3:0 > 1011
145 at8xc51snd2c 4341e?mp3?06/05 figure 95. data controller co nfiguration flows data transmitter configuration for transmitting data to the card user must first configure th e data controller in transmis- sion mode by setting the datdir bit in mmcon1 register. figure 96 summarizes the data stream transmis sion flows in both polling and interrupt modes while figure 97 summarizes the data block transmission flows in both polling and interrupt modes, these flows assume that block length is greater than 16 data. data loading data is loaded in the fifo by writing to mmdat register . number of data loaded may vary from 1 to 16 bytes. then if necessary (more than 16 bytes to send) user must wait that one fifo becomes empty (f1ei or f2ei set) before loading 8 new data. data transmission transmission is enabled by setting and clearing daten bit in mmcon1 register. data is transmitted immediatel y if the response has already been received, or is delayed after the respon se reception if its status is correct. in both ca ses transmission is delayed if a card sends a busy state on the data line until the end of this busy condition. according to the mmc specification, the data tr ansfer from the host to the card may not start sooner than 2 mmc clock periods afte r the card response was received (formally n wr parameter). to address all card types, this delay can be programmed using datd1:0 bits in mmcon2 register from 3 mmc clock periods w hen datd1:0 bits are cleared to 9 mmc clock peri ods when datd1:0 bits are se t, by step of 2 mmc clock periods. end of transmission the end of a data frame (block or stream) transmission is signalled to you by the eofi flag in mmint register. this flag may generate an mmc interrupt request as detailed in section "interrupt", page 150. in data stream mode, eofi flag is set, afte r reception of the end bit. this assumes user has previously sent the stop command to the card, which is the only way to stop stream transfer. in data block mode, eofi flag is set, after reception of the crc status token (see figure 87). 2 other flags in mmsta register: datfs and crc16s report a status on the frame sent. datfs indicates if the crc st atus token format is correct or not, and crc16s indicates if the card has found the crc16 of the block correct or not. busy status as shown in figure 87 the card uses a busy token during a block write operation. this busy status is reported to you by the cbusy flag in mmsta register and by the mcbi flag in mmint which is set every time cbu sy toggles, i.e. when the card enters and exits its busy state. this flag may generate an mmc interrupt request as detailed in sec- tion "interrupt", page 150. data single block configuration data stream configuration configure format dfmt = 0 data multi-block configuration configure format dfmt = 1 mblock = 1 blen3:0 = xxxxb configure format dfmt = 1 mblock = 0 blen3:0 = xxxxb
146 at8xc51snd2c 4341e?mp3?06/05 figure 96. data stream transmission flows send stop command data stream transmission start transmission daten = 1 daten = 0 fifo empty? f1ei or f2ei = 1? fifo filling write 8 data to mmdat no more data to send? fifos filling write 16 data to mmdat a. polling mode data stream initialization fifos filling write 16 data to mmdat data stream transmission isr fifo filling write 8 data to mmdat send stop command no more data to send? b. interrupt mode fifo empty? f1ei or f2ei = 1? start transmission daten = 1 daten = 0 unmask fifos empty f1em = 0 f2em = 0 mask fifos empty f1em = 1 f2em = 1
147 at8xc51snd2c 4341e?mp3?06/05 figure 97. data block transmission flows data receiver configuration to receive data from the card you must first configure the data controller in reception mode by clearing the datdir bit in mmcon1 register. figure 98 summarizes the data stream reception flows in both polling and interrupt modes while figure 99 summarizes the data block reception flows in both polling and interrupt modes, these flow s assume that block length is greater than 16 bytes. data reception the end of a data frame (block or stream) rece ption is signalled to you by the eofi flag in mmint register. this flag may generate an mmc interrupt reques t as detailed in sec- tion "interrupt", page 150. when this flag is set, 2 other flags in mmsta register: datfs and crc16s give a status on the frame rece ived. datfs indicates if the frame format is correct or not: a valid end bit has been received, and crc16s indicates if the crc16 computation is correct or not. in case of data stream crc16s has no meaning and stays cleared. according to the mmc specification data tr ansmission from the card starts after the access time delay (formally n ac parameter) beginning from the end bit of the read com- mand. to avoid any locking of the mmc controller when card does not send its data (e.g. physically removed from the bus), you must launch a time-out period to exit from such situation. in case of ti me-out you may reset the data controller and its internal state machine by setting and clearing the dcr bit in mmcon2 register. data block transmission start transmission daten = 1 daten = 0 fifo empty? f1ei or f2ei = 1? fifo filling write 8 data to mmdat no more data to send? fifos filling write 16 data to mmdat a. polling mode data block initialization start transmission daten = 1 daten = 0 fifos filling write 16 data to mmdat data block transmission isr fifo filling write 8 data to mmdat no more data to send? b. interrupt mode fifo empty? f1ei or f2ei = 1? mask fifos empty f1em = 1 f2em = 1 unmask fifos empty f1em = 0 f2em = 0
148 at8xc51snd2c 4341e?mp3?06/05 this time-out may be disarmed after receiving 8 data (f1fi flag set) or after receiving end of frame (eofi flag set) in case of bl ock length less than 8 data (1, 2 or 4). data reading data is read from the fifo by reading to mmdat register. each time one fifo becomes full (f1fi or f2fi set), user is requ ested to flush this fifo by reading 8 data. figure 98. data stream reception flows data stream reception fifo full? f1fi or f2fi = 1? fifo reading read 8 data from mmdat no more data to receive? a. polling mode data stream initialization data stream reception isr fifo reading read 8 data from mmdat send stop command no more data to receive? b. interrupt mode fifo full? f1fi or f2fi = 1? unmask fifos full f1fm = 0 f2fm = 0 send stop command mask fifos full f1fm = 1 f2fm = 1
149 at8xc51snd2c 4341e?mp3?06/05 figure 99. data block reception flows flow control to allow transfer at high speed without taking care of cpu oscillator frequency, the flowc bit in mmcon2 allows control of th e data flow in both transmission and reception. during transmission, setting the flowc bit has the following effects: ? mmclk is stopped when both fifos become empty: f1ei and f2ei set. ? mmclk is restarted when one of the fi fos becomes full: f1ei or f2ei cleared. during reception, setting the flowc bit has the following effects: ? mmclk is stopped when both fifos become full: f1fi and f2fi set. ? mmclk is restarted when one of the fifos becomes empty: f1fi or f2fi cleared. as soon as the clock is stoppe d, the mmc bus is frozen and remains in its state until the clock is restored by writin g or reading data in mmdat. data block reception start transmission daten = 1 daten = 0 fifo full? f1ei or f2ei = 1? fifo reading read 8 data from mmdat no more data to receive? a. polling mode data block initialization start transmission daten = 1 daten = 0 data block reception isr fifo reading read 8 data from mmdat no more data to receive? b. interrupt mode fifo full? f1ei or f2ei = 1? mask fifos full f1fm = 1 f2fm = 1 unmask fifos full f1fm = 0 f2fm = 0
150 at8xc51snd2c 4341e?mp3?06/05 interrupt description as shown in figure 100, the mmc controller im plements eight interrupt sources reported in mcbi, eori, eoci, eofi, f2fi, f1fi, a nd f2ei flags in mmci nt register. these flags are detailed in the previous sections. all these sources are maskab le separately using mcbm , eorm, eocm, eofm, f2fm, f1fm, and f2em mask bits respectively in mmmsk register. the interrupt request is generated each time an unmasked flag is set, and the global mmc controller interrupt enable bit is set (emmc in ien1 register). reading the mmint register automatically clears the interrupt flags (acknowledgment). this implies that register c ontent must be saved and tested interrupt flag by interrupt flag to be sure not to forget any interrupts. figure 100. mmc controller interrupt system mmc interface interrupt request mcbi mmint.7 eocm mmmsk.5 emmc ien1.0 mcbm mmmsk.7 eorm mmmsk.6 eofi mmint.4 f2fm mmmsk.3 eofm mmmsk.4 eori mmint.6 f2fi mmint.3 eoci mmint.5 f2em mmmsk.1 f1fm mmmsk.2 f1ei mmint.0 f1em mmmsk.0 f1fi mmint.2 f2ei mmint.1
151 at8xc51snd2c 4341e?mp3?06/05 registers table 145. mmcon0 register mmcon0 (s:e4h) ? mmc control register 0 reset value = 0000 0000b 76543210 drptr dtptr crptr ctptr mblock dfmt rfmt crcdis bit number bit mnemonic description 7drptr data receive pointer reset bit set to reset the read pointer of the data fifo. clear to release the read pointer of the data fifo. 6 dtptr data transmit pointer reset bit set to reset the write pointer of the data fifo. clear to release the write pointer of the data fifo. 5crptr command receive pointer reset bit set to reset the read pointer of the receive command fifo. clear to release the read pointer of the receive command fifo. 4 ctptr command transmit pointer reset bit set to reset the write pointer of the transmit command fifo. clear to release the read pointer of the transmit command fifo. 3mblock multi-block enable bit set to select multi-block data format. clear to select single block data format. 2dfmt data format bit set to select the block-oriented data format. clear to select the stream data format. 1rfmt response format bit set to select the 48-bit response format. clear to select the 136-bit response format. 0 crcdis crc7 disable bit set to disable the crc7 computation when receiving a response. clear to enable the crc7 computation when receiving a response.
152 at8xc51snd2c 4341e?mp3?06/05 table 146. mmcon1 register mmcon1 (s:e5h) ? mmc control register 1 reset value = 0000 0000b table 147. mmcon2 register mmcon2 (s:e6h) ? mmc control register 2 reset value = 0000 0000b 76543210 blen3 blen2 blen1 blen0 datdir daten respen cmden bit number bit mnemonic description 7 - 4 blen3:0 block length bits refer to table 144 for bits description. do not program value > 1011b 3datdir data direction bit set to select data transfer from host to card (write mode). clear to select data transfer from card to host (read mode). 2daten data transmission enable bit set and clear to enable data transmission immediately or after response has been received. 1 respen response enable bit set and clear to enable the reception of a response following a command transmission. 0cmden command transmission enable bit set and clear to enable transmission of the command fifo to the card. 76543210 mmcen dcr ccr - - datd1 datd0 flowc bit number bit mnemonic description 7 mmcen mmc clock enable bit set to enable the mclk clocks and activate the mmc controller. clear to disable the mmc clocks and freeze the mmc controller. 6dcr data controller reset bit set and clear to reset the data line controller in case of transfer abort. 5ccr command controller reset bit set and clear to reset the command line controller in case of transfer abort. 4-3 - reserved the value read from these bits is always 0. do not set these bits. 2-1 datd1:0 data transmission delay bits used to delay the data transmission afte r a response from 3 mmc clock periods (all bits cleared) to 9 mmc clock periods (all bits set) by step of 2 mmc clock periods. 0flowc mmc flow control bit set to enable the flow control during data transfers. clear to disable the flow control during data transfers.
153 at8xc51snd2c 4341e?mp3?06/05 table 148. mmsta register mmsta (s:deh read only) ? mmc control and status register reset value = 0000 0000b 76543210 - - cbusy crc16s datfs crc7s respfs cflck bit number bit mnemonic description 7 - 6 - reserved the value read from these bits is always 0. do not set these bits. 5 cbusy card busy flag set by hardware when the card sends a busy state on the data line. cleared by hardware when the card no more sends a busy state on the data line. 4 crc16s crc16 status bit transmission mode set by hardware when the token response reports a good crc. cleared by hardware when the token response reports a bad crc. reception mode set by hardware when the crc16 received in the data block is correct. cleared by hardware when the crc16 received in the data block is not correct. 3datfs data format status bit transmission mode set by hardware when the format of the token response is correct. cleared by hardware when the format of the token response is not correct. reception mode set by hardware when the format of the frame is correct. cleared by hardware when the format of the frame is not correct. 2 crc7s crc7 status bit set by hardware when the crc7 computed in the response is correct. cleared by hardware when the crc7 computed in the response is not correct. this bit is not relevant when crcdis is set. 1 respfs response format status bit set by hardware when the format of a response is correct. cleared by hardware when the format of a response is not correct. 0cflck command fifo lock bit set by hardware to signal user not to write in the transmit command fifo: busy state. cleared by hardware to signal user the tr ansmit command fifo is available: idle state.
154 at8xc51snd2c 4341e?mp3?06/05 table 149. mmint register mmint (s:e7h read only) ? mmc interrupt register reset value = 0000 0011b 76543210 mcbi eori eoci eofi f2fi f1fi f2ei f1ei bit number bit mnemonic description 7mcbi mmc card busy interrupt flag set by hardware when the card enters or exits its busy state (when the busy signal is asserted or deasserted on the data line). cleared when reading mmint. 6eori end of response interrupt flag set by hardware at the end of response reception. cleared when reading mmint. 5eoci end of command interrupt flag set by hardware at the end of command transmission. clear when reading mmint. 4eofi end of frame interrupt flag set by hardware at the end of frame (stream or block) transfer. clear when reading mmint. 3f2fi fifo 2 full interrupt flag set by hardware when second fifo becomes full. cleared by hardware when second fifo becomes empty. 2f1fi fifo 1 full interrupt flag set by hardware when first fifo becomes full. cleared by hardware when first fifo becomes empty. 1f2ei fifo 2 empty interrupt flag set by hardware when second fifo becomes empty. cleared by hardware when second fifo becomes full. 0f1ei fifo 1 empty interrupt flag set by hardware when first fifo becomes empty. cleared by hardware when first fifo becomes full.
155 at8xc51snd2c 4341e?mp3?06/05 table 150. mmmsk register mmmsk (s:dfh) ? mmc interrupt mask register reset value = 1111 1111b table 151. mmcmd register mmcmd (s:ddh) ? mmc command register reset value = 1111 1111b 76543210 mcbm eorm eocm eofm f2fm f1fm f2em f1em bit number bit mnemonic description 7mcbm mmc card busy interrupt mask bit set to prevent mcbi flag from generating an mmc interrupt. clear to allow mcbi flag to generate an mmc interrupt. 6eorm end of response interrupt mask bit set to prevent eori flag from generating an mmc interrupt. clear to allow eori flag to generate an mmc interrupt. 5eocm end of command interrupt mask bit set to prevent eoci flag from generating an mmc interrupt. clear to allow eoci flag to generate an mmc interrupt. 4eofm end of frame interrupt mask bit set to prevent eofi flag from generating an mmc interrupt. clear to allow eofi flag to generate an mmc interrupt. 3f2fm fifo 2 full interrupt mask bit set to prevent f2fi flag from generating an mmc interrupt. clear to allow f2fi flag to generate an mmc interrupt. 2f1fm fifo 1 full interrupt mask bit set to prevent f1fi flag from generating an mmc interrupt. clear to allow f1fi flag to generate an mmc interrupt. 1f2em fifo 2 empty interrupt mask bit set to prevent f2ei flag from generating an mmc interrupt. clear to allow f2ei flag to generate an mmc interrupt. 0f1em fifo 1 empty interrupt mask bit set to prevent f1ei flag from generating an mmc interrupt. clear to allow f1ei flag to generate an mmc interrupt. 76543210 mc7 mc6 mc5 mc4 mc3 mc2 mc1 mc0 bit number bit mnemonic description 7 - 0 mc7:0 mmc command receive byte output (read) register of the response fifo. mmc command transmit byte input (write) register of the command fifo.
156 at8xc51snd2c 4341e?mp3?06/05 table 152. mmdat register mmdat (s:dch) ? mmc data register reset value = 1111 1111b table 153. mmclk register mmclk (s:edh) ? mmc clock divider register reset value = 0000 0000b 76543210 md7 md6 md5 md4 md3 md2 md1 md0 bit number bit mnemonic description 7 - 0 md7:0 mmc data byte input (write) or output (read) register of the data fifo. 76543210 mmcd7 mmcd6 mmcd5 mmcd4 mmcd3 mmcd2 mmcd1 mmcd0 bit number bit mnemonic description 7 - 0 mmcd7:0 mmc clock divider 8-bit divider for mmc clock generation.
157 at8xc51snd2c 4341e?mp3?06/05 synchronous peripheral interface the at8xc51snd2c implements a synchronous peripheral interface with master and slave modes capability. figure 101 shows an spi bus configuration using the at8xc51snd2c as master con- nected to slave peripherals while figure 102 shows an spi bus configuration using the at8xc51snd2c as slave of an other master. the bus is made of three wires connecting all the devices together: ? master output slave input (mosi): it is us ed to transfer data in series from the master to a slave. it is driven by the master. ? master input slave output (miso): it is used to transfer data in series from a slave to the master. it is driven by the selected slave. ? serial clock (sck): it is used to synchronize the data transmission both in and out the devices through their mosi and miso lines . it is driven by the master for eight clock cycles which allows to exchange one byte on the serial lines. each slave peripheral is selected by one slave select pin (ss ). if there is only one slave, it may be continuously selected with ss tied to a low level. otherwise, the at8xc51snd2c may select each device by software through port pins (pn.x). special care should be taken not to select 2 slaves at the same time to avoid bus conflicts. figure 101. typical master spi bus configuration figure 102. typical slave spi bus configuration at8xc51snd2c dataflash 1 ss miso mosi sck p4.0 p4.1 p4.2 pn.z pn.y pn.x so si sck dataflash 2 ss so si sck lcd controller ss so si sck master slave 1 ss miso mosi sck ssn ss1 ss0 so si sck slave 2 ss so si sck at8xc51snd2c slave n ss miso mosi sck
158 at8xc51snd2c 4341e?mp3?06/05 description the spi controller interfaces with the c51 co re through three special function registers: spcon, the spi control register (see table 155); spsta, the spi status register (see table 156); and spdat, the spi data register (see table 157). master mode the spi operates in master mode when the mstr bit in spcon is set. figure 103 shows the spi block diagram in master mode. only a master spi module can initiate transmissions. software begins the transmission by writing to spdat. writ- ing to spdat writes to the shift regist er while reading spdat reads an intermediate register updated at the end of each transfer. the byte begins shifting out on the mosi pin under the control of the bit rate generator. this generator also controls the shift regist er of the slave peripheral through the sck output pin. as the byte shifts out, another by te shifts in from the slave peripheral on the miso pin. the byte is transmitted most sign ificant bit (msb) first. the end of transfer is signaled by spif being set. when the at8xc51snd2c is the only master on the bus, it can be useful not to use ss# pin and get it back to i/o functionality. this is achieved by setting ssdis bit in spcon. figure 103. spi master mode block diagram note: mstr bit in spcon is set to select master mode. bit rate generator spr2:0 spcon mosi/p4.1 miso/p4.0 sck/p4.2 cpol spcon.3 spen spcon.6 cpha spcon.2 per clock 8-bit shift register spdat wr iq internal bus spdat rd control and clock logic modf spsta.4 ss#/p4.3 ssdis spcon.5 wcol spsta.6 spif spsta.7
159 at8xc51snd2c 4341e?mp3?06/05 slave mode the spi operates in slave mode when the mstr bit in spcon is cleared and data has been loaded in spdat. figure 104 shows the spi block diagram in slave mode. in slave mode, before a data transmission occurs, the ss pin of the slave spi must be asserted to low level. ss must remain low until the transmission of the byte is complete. in the slave spi module, data enters the shift register through the mosi pi n under the control of the serial clock pro- vided by the master spi module on the sck input pin. when the master starts a transmission, the data in the shift register begins shifting out on the miso pin. the end of transfer is signaled by spif being set. when the at8xc51snd2c is the only slave on the bus, it can be useful not to use ss# pin and get it back to i/o functionality. this is achieved by setting ssdis bit in spcon. this bit has no effect when cpha is cleared (see section "ss management", page 161). figure 104. spi slave mode block diagram note: 1. mstr bit in spcon is cleared to select slave mode. bit rate the bit rate can be selected from seven predefined bit rates using the spr2, spr1 and spr0 control bits in spcon according to table 154. these bit rates are derived from the peripheral clock (f per ) issued from the clock controller block as detailed in section "oscillator", page 12. miso/p4.2 mosi/p4.1 ss /p4.3 spif spsta.7 cpol spcon.3 cpha spcon.2 8-bit shift register spdat wr iq internal bus spdat rd sck/p4.2 ssdis spcon.5 control and clock logic
160 at8xc51snd2c 4341e?mp3?06/05 table 154. serial bit rates notes: 1. these frequencies are achieved in x1 mode, f per = f osc y 2. 2. these frequencies are achieved in x2 mode, f per = f osc . data transfer the clock polarity bit (cpol in spcon) defines the default sck line level in idle state (1) while the clock phase bit (cpha in spcon) defines the edges on which the input data are sampled and the edges on which the output data are shifted (see figure 105 and figure 106). the si signal is output from the selected slave and the so signal is the output from the master. the at 8xc51snd2c captures data from the si line while the selected slave captures data from the so line. for simplicity, figure 105 and figure 106 d epict the spi waveforms in idealized form and do not provide precise timing information. for timing parameters refer to the section ?ac characteristics?. note: 1. when the peripher al is disabled (spen = 0), default sck line is high level. figure 105. data transmission format (cpha = 0) spr2 spr1 spr0 bit rate (khz) vs f per f per divider 6 mhz (1) 8 mhz (1) 10 mhz (1) 12 mhz (2) 16 mhz (2) 20 mhz (2) 0 0 0 3000 4000 5000 6000 8000 10000 2 0 0 1 1500 2000 2500 3000 4000 5000 4 0 1 0 750 1000 1250 1500 2000 2500 8 0 1 1 375 500 625 750 1000 1250 16 1 0 0 187.5 250 312.5 375 500 625 32 1 0 1 93.75 125 156.25 187.5 250 312.5 64 1 1 0 46.875 62.5 78.125 93.75 125 156.25 128 1 1 1 6000 8000 10000 12000 16000 20000 1 1 2 3 4 5 6 7 8 msb bit 1 lsb bit 2 bit 4 bit 3 bit 6 bit 5 bit 1 bit 2 bit 4 bit 3 bit 6 bit 5 msb lsb mosi (from master) miso (from slave) sck (cpol = 1) sck (cpol = 0) spen (internal) sck cycle number ss (to slave) capture point
161 at8xc51snd2c 4341e?mp3?06/05 figure 106. data transmission format (cpha = 1) ss management figure 105 shows an spi transmission with cpha = 0, where the first sck edge is the msb capture point. therefore the slave starts to output its msb as soon as it is selected: ss asserted to low level. ss must then be deasserted between each byte transmission (see figure 107). spdat must be loaded with a data before ss is asserted again. figure 106 shows an spi transmission with cpha = 1, where the first sck edge is used by the slave as a start of transmission signal. therefore, ss may remain asserted between each byte transmission (see figure 107). figure 107. ss timing diagram error conditions the following flags signal the spi error conditions: ? modf in spsta signals a mode fault. modf flag is relevant only in master mode when ss usage is enabled (ssdis bit cleared). it signals when set that an ot her master on the bus has asserted ss pin and so, may create a conflict on the bus with 2 master sending data at the same time. ? a mode fault automatically disables the spi (spen cleared) and configures the spi in slave mode (mstr cleared). modf flag can trigger an interrupt as explained in section "interrupt", page 162. modf flag is cleared by reading spsta and re-configuring spi by writing to spcon. ? wcol in spsta signals a write collision. wcol flag is set when spdat is loaded while a transfer is on-go ing. in this case data is not written to spdat and transfer continue uninterrupted. wcol flag does not trigger any interrupt and is relevant jointly with spif flag. wcol flag is cleared after reading spsta a nd writing new data to spdat while no transfer is on-going. 1 2 3 4 5 6 7 8 msb bit 1 lsb bit 2 bit 4 bit 3 bit 6 bit 5 bit 1 bit 2 bit 4 bit 3 bit 6 bit 5 msb lsb mosi (from master) miso (from slave) sck (cpol = 1) sck (cpol = 0) spen (internal) sck cycle number ss (to slave) capture point ss (cpha = 1) ss (cpha = 0) si/so byte 1 byte 2 byte 3
162 at8xc51snd2c 4341e?mp3?06/05 interrupt the spi handles 2 interrupt sources that are the ?end of transfer? and the ?mode fault? flags. as shown in figure 108, these flags are combined toghether to appear as a single inter- rupt source for the c51 core. the spif flag is set at the end of an 8-bit shift in and out and is cleared by reading spsta and then reading from or writing to spdat. the modf flag is set in case of mode fa ult error and is clea red by reading spsta and then writing to spcon. the spi interrupt is enabled by setting espi bit in ien1 register. this assumes inter- rupts are globally enabled by setting ea bit in ien0 register. figure 108. spi interrupt system espi ien1.2 spi controller interrupt request spif spsta.7 modf spsta.4
163 at8xc51snd2c 4341e?mp3?06/05 configuration the spi configuration is made through spcon. master configuration the spi operates in master mode when the mstr bit in spcon is set. slave configuration the spi operates in slave mode when the mstr bit in spcon is cleared and data has been loaded is spdat. data exchange there are 2 possible methods to exchan ge data in master and slave modes: ? polling ? interrupts master mode with polling policy figure 109 shows the in itialization phase and the transfer phase flows using the polling method. using this flow prevent s any overrun error occurrence. the bit rate is selected according to table 154. the transfer format depends on the slave peripheral. ss may be deasserted between transfers depending also on the slave peripheral. spif flag is cleared when re ading spdat (spsta has been read before by the ?end of transfer? check). this polling method provides the fastest effective transmis sion and is well adapted when communicating at high speed wi th other microcontrollers. however, the procedure may then be interrupted at any time by higher priority tasks. figure 109. master spi polling flows spi initialization polling policy disable interrupt spie = 0 spi transfer polling policy end of transfer? spif = 1? select master mode mstr = 1 select bit rate program spr2:0 select format program cpol & cpha enable spi spen = 1 select slave pn.x = l start transfer write data in spdat last transfer? get data received read spdat deselect slave pn.x = h
164 at8xc51snd2c 4341e?mp3?06/05 master mode with interrupt figure 110 shows the initialization phase and the transfer phase flow s using the inter- rupt. using this flow prevents any overrun error occurrence. the bit rate is selected according to table 154. the transfer format depends on the slave peripheral. ss may be deasserted between transfers depending also on the slave peripheral. reading spsta at the beginning of the isr is mandatory for cl earing the spif flag. clear is effective when reading spdat. figure 110. master spi interrupt flows spi initialization interrupt policy enable interrupt espi =1 spi interrupt service routine select master mode mstr = 1 select bit rate program spr2:0 select format program cpol & cpha enable spi spen = 1 read status read spsta start new transfer write data in spdat last transfer? get data received read spdat disable interrupt spie = 0 select slave pn.x = l start transfer write data in spdat deselect slave pn.x = h
165 at8xc51snd2c 4341e?mp3?06/05 slave mode with polling policy figure 111 shows the initializat ion phase and the transfer phase flows using the polling. the transfer format depends on the master controller. spif flag is cleared when re ading spdat (spsta has been read before by the ?end of reception? check). this provides the fastest effective tr ansmission and is well adapted when communicat- ing at high speed with othe r microcontrollers. however, the process may then be interrupted at any time by higher priority tasks. figure 111. slave spi polling flows spi initialization polling policy disable interrupt spie = 0 spi transfer polling policy data received? spif = 1? select slave mode mstr = 0 select format program cpol & cpha enable spi spen = 1 prepare next transfer write data in spdat get data received read spdat prepare transfer write data in spdat
166 at8xc51snd2c 4341e?mp3?06/05 slave mode with interrupt policy figure 110 shows the initialization phase and the transfer phase flows using the interrupt. the transfer format depends on the master controller. reading spsta at the beginning of the isr is mandatory for cl earing the spif flag. clear is effective when reading spdat. figure 112. slave spi interrupt policy flows spi initialization interrupt policy enable interrupt espi =1 spi interrupt service routine select slave mode mstr = 0 select format program cpol & cpha enable spi spen = 1 get status read spsta prepare new transfer write data in spdat get data received read spdat prepare transfer write data in spdat
167 at8xc51snd2c 4341e?mp3?06/05 registers table 155. spcon register spcon (s:c3h) ? spi control register reset value = 0001 0100b note: 1. when the spi is disabled, sck outputs high level. 76543210 spr2 spen ssdis mstr cpol cpha spr1 spr0 bit number bit mnemonic description 7 spr2 spi rate bit 2 refer to table 154 for bit rate description. 6 spen spi enable bit set to enable the spi interface. clear to disable the spi interface. 5 ssdis slave select input disable bit set to disable ss in both master and slave modes. in slave mode this bit has no effect if cpha = 0. clear to enable ss in both master and slave modes. 4mstr master mode select set to select the master mode. clear to select the slave mode. 3cpol spi clock polarity bit (1) set to have the clock output set to high level in idle state. clear to have the clock output set to low level in idle state. 2cpha spi clock phase bit set to have the data sampled when the clock returns to idle state (see cpol). clear to have the data sampled when the clock leaves the idle state (see cpol). 1 - 0 spr1:0 spi rate bits 0 and 1 refer to table 154 for bit rate description.
168 at8xc51snd2c 4341e?mp3?06/05 table 156. spsta register spsta (s:c4h) ? spi status register reset value = 00000 0000b table 157. spdat register spdat (s:c5h) ? synchronous serial data register reset value = xxxx xxxxb 76543210 spifwcol-modf---- bit number bit mnemonic description 7 spif spi interrupt flag set by hardware when an 8-bit shift is completed. cleared by hardware when reading or writing spdat after reading spsta. 6wcol write collision flag set by hardware to indicate that a collision has been detected. cleared by hardware to indicate t hat no collision has been detected. 5- reserved the value read from this bit is i ndeterminate. do not set this bit. 4modf mode fault set by hardware to indicate that the ss pin is at an appropriate level. cleared by hardware to indicate that the ss pin is at an inappropriate level. 3 - 0 - reserved the value read from these bits is i ndeterminate. do not set these bits. 76543210 spd7 spd6 spd5 spd4 spd3 spd2 spd1 spd0 bit number bit mnemonic description 7 - 0 spd7:0 synchronous serial data.
169 at8xc51snd2c 4341e?mp3?06/05 serial i/o port the serial i/o port in the at8xc51snd2c provides both synchronous and asynchro- nous communication modes. it operates as a synchronous receiver and transmitter in one single mode (mode 0) and operates as an universal asynchronous receiver and transmitter (uart) in three full-duplex modes (modes 1, 2 and 3). asynchronous modes support framing error detection and multiprocessor communication with auto- matic address recognition. mode selection sm0 and sm1 bits in scon register (see figure 160) are used to select a mode among the single synchronous and the three asyn chronous modes according to table 158. table 158. serial i/o port mode selection baud rate generator depending on the mode and the source selection, the baud rate can be generated from either the timer 1 or the internal baud rate generator. the timer 1 can be used in modes 1 and 3 while the internal baud rate generator can be used in modes 0, 1 and 3. the addition of the internal baud rate generator allows freeing of the timer 1 for other purposes in the application. it is highly recommended to use the internal baud rate generator as it allows higher and more accurate baud rates than timer 1. baud rate formulas depend on the modes selected and are given in the following mode sections. timer 1 when using timer 1, the baud rate is derived from the overflow of the timer. as shown in figure 113 timer 1 is used in its 8-bit auto-reload mode (detailed in section "mode 2 (8-bit timer with auto-reload)", page 53). sm od1 bit in pcon register allows doubling of the generated baud rate. figure 113. timer 1 baud rate generator block diagram sm0 sm1 mode description baud rate 0 0 0 synchronous shift register fixed/variable 0 1 1 8-bit uart variable 10 29-bit uart fixed 1 1 3 9-bit uart variable tr1 tcon.6 0 1 gate1 tmod.7 overflow c/t1# tmod.6 tl1 (8 bits) th1 (8 bits) int1 t1 per clock y 6 0 1 smod1 pcon.7 y 2 t1 clock to serial port
170 at8xc51snd2c 4341e?mp3?06/05 internal baud rate generator when using the internal baud rate generator, the baud rate is derived from the over- flow of the timer. as shown in figure 114 the internal baud rate generator is an 8-bit auto-reload timer fed by the peripheral clo ck or by the peripheral clock divided by 6 depending on the spd bit in bdrcon register (see table 164). the internal baud rate generator is enabled by setting bbr bit in bdrcon register. smod1 bit in pcon reg- ister allows doubling of the generated baud rate. figure 114. internal baud rate generator block diagram synchronous mode (mode 0) mode 0 is a half-duplex, synchronous mode, which is commonly used to expand the i/0 capabilities of a device with shift registers. the transmit data (txd) pin outputs a set of eight clock pulses while the receive data (rxd ) pin transmits or receives a byte of data. the 8-bit data are transmitted and received leas t-significant bit (lsb) first. shifts occur at a fixed baud rate (see section "b aud rate selection (mode 0)", page 171). figure 115 shows the serial port block diagram in mode 0. figure 115. serial i/o port block diagram (mode 0) transmission (mode 0) to start a transmission mode 0, write to scon register clearing bits sm0, sm1. as shown in figure 116, writing the byte to transmit to sbuf register starts the trans- mission. hardware shifts the lsb (d0) ont o the rxd pin during the first clock cycle composed of a high level then low level signal on txd. during the eighth clock cycle the msb (d7) is on the rxd pin. then, hardware drives the rxd pin high and asserts ti to indicate the end of the transmission. 0 1 overflow spd bdrcon.1 brg (8 bits) brl (8 bits) per clock y 6 ibrg clock brr bdrcon.4 0 1 smod1 pcon.7 y 2 to serial port ibrg0 clock to serial port (m0) brg clock txd rxd sbuf tx sr sbuf rx sr sm1 scon.6 sm0 scon.7 mode decoder m3 m2 m1 m0 mode controller ri scon.0 ti scon.1 per clock baud rate controller
171 at8xc51snd2c 4341e?mp3?06/05 figure 116. transmission waveforms (mode 0) reception (mode 0) to start a reception in mode 0, write to scon register clearing sm0, sm1 and ri bits and setting the ren bit. as shown in figure 117, clock is pulsed and the lsb (d0) is sampled on the rxd pin. the d0 bit is then shifted into the shift regi ster. after eight samplings, the msb (d7) is shifted into the shift register, and hardware as serts ri bit to indicate a completed recep- tion. software can then read the received byte from sbuf register. figure 117. reception waveforms (mode 0) baud rate selection (mode 0) in mode 0, the baud rate can be either, fixed or variable. as shown in figure 118, the selection is done using m0src bit in bdrcon register. figure 119 gives the baud rate calculation formulas for each baud rate source. figure 118. baud rate source selection (mode 0) figure 119. baud rate formulas (mode 0) write to sbuf txd rxd ti d0 d1 d2 d3 d4 d5 d6 d7 write to scon txd rxd ri d0 d1 d2 d3 d4 d5 d6 d7 set ren, clear ri 0 1 m0src bdrcon.0 per clock y 6 to serial port ibrg0 clock baud_rate= 6 (1-spd) ? 16 ? (256 -brl) f per brl= 256 - 6 (1-spd) ? 16 ? baud_rate f per a. fixed formula b. variable formula baud_rate = 6 f per
172 at8xc51snd2c 4341e?mp3?06/05 asynchronous modes (modes 1, 2 and 3) the serial port has one 8-bit and 2 9-bit asynchronous modes of operation. figure 120 shows the serial port block diag ram in such asynchronous modes. figure 120. serial i/o port block diagram (modes 1, 2 and 3) mode 1 mode 1 is a full-duplex, asynchronous mode. the data frame (see figure 121) consists of 10 bits: one start, eight data bits and one stop bit. serial data is transmitted on the txd pin and received on the rxd pin. when a data is received, the stop bit is read in the rb8 bit in scon register. figure 121. data frame format (mode 1) modes 2 and 3 modes 2 and 3 are full-duplex, asynchronous modes. the data frame (see figure 122) consists of 11 bits: one star t bit, eight data bits (transmi tted and received lsb first), one programmable ninth data bit and one stop bit. serial data is transmitted on the txd pin and received on the rxd pin. on receive, the ninth bit is read from rb8 bit in scon register. on transmit, the ninth data bit is wr itten to tb8 bit in sc on register. alterna- tively, you can use the ninth bit c an be used as a command/data flag. figure 122. data frame format (modes 2 and 3) transmission (modes 1, 2 and 3) to initiate a transmission, write to scon register, set the sm0 and sm1 bits according to table 158, and set the ninth bit by writi ng to tb8 bit. then, writing the byte to be transmitted to sbuf register starts the transmission. reception (modes 1, 2 and 3) to prepare for reception, write to scon register, set the sm0 and sm1 bits according to table 158, and set the ren bit. the actual rec eption is then initiated by a detected high- to-low transition on the rxd pin. tb8 scon.3 ibrg clock rxd txd sbuf tx sr rx sr sm1 scon.6 sm0 scon.7 mode decoder m3 m2 m1 m0 ri scon.0 ti scon.1 mode & clock controller sbuf rx rb8 scon.2 sm2 scon.4 t1 clock per clock mode 1 d0 d1 d2 d3 d4 d5 d6 d7 start bit 8-bit data stop bit d0 d1 d2 d3 d4 d5 d6 d8 start bit 9-bit data stop bit d7
173 at8xc51snd2c 4341e?mp3?06/05 framing error detection (modes 1, 2 and 3) framing error detection is provided for the three asynchronous modes. to enable the framing bit error detection feature, set smod0 bit in pcon register as shown in figure 123. when this feature is enabled, the receiver checks each incoming dat a frame for a valid stop bit. an invalid stop bit ma y result from noise on the serial lines or from simultaneous transmission by 2 devices. if a valid stop bi t is not found, the software sets fe bit in scon register. software may examine fe bit after each reception to check for data errors. once set, only software or a chip reset clear fe bit. subsequently received frames with valid stop bits cannot clear fe bit. when the framing erro r detection feature is enabled, ri rises on stop bit instead of the last data bit as detailed in figure 129. figure 123. framing error block diagram baud rate selection (modes 1 and 3) in modes 1 and 3, the baud rate is derived either from the timer 1 or the internal baud rate generator and allows different baud rate in reception and transmission. as shown in figure 124 the selection is done using rbck and tbck bits in bdrcon register. figure 125 gives the baud rate calculation formulas for each baud rate source while table 159 details internal baud rate generator configuration for different peripheral clock frequencies and giving baud rates closer to the standard baud rates. figure 124. baud rate source selection (modes 1 and 3) figure 125. baud rate formulas (modes 1 and 3) sm0 1 0 smod0 pcon.6 sm0/fe scon.7 framing error controller fe 0 1 rbck bdrcon.2 t1 clock to serial ibrg clock rx port 0 1 tbck bdrcon.3 t1 clock to serial ibrg clock tx port y 16 y 16 baud_rate= 6 (1-spd) ? 32 ? (256 -brl) 2 smod1 ? f per brl= 256 - 6 (1-spd) ? 32 ? baud_rate 2 smod1 ? f per baud_rate= 6 ? 32 ? (256 -th1) 2 smod1 ? f per th1= 256 - 192 ? baud_rate 2 smod1 ? f per a. ibrg formula b. t1 formula
174 at8xc51snd2c 4341e?mp3?06/05 notes: 1. these frequencies are achieved in x1 mode, f per = f osc y 2. 2. these frequencies are achieved in x2 mode, f per = f osc . baud rate selection (mode 2) in mode 2, the baud rate can only be programmed to 2 fixed values: 1/16 or 1/32 of the peripheral clock frequency. as shown in figure 126 the selection is done using smod1 bit in pcon register. figure 127 gives the baud rate calculat ion formula depending on the selection. figure 126. baud rate generator selection (mode 2) table 159. internal baud rate generator value baud rate f per = 6 mhz (1) f per = 8 mhz (1) f per = 10 mhz (1) spd smod1 brl error % spd smod1 brl error % spd smod1 brl error % 115200 - ----------- 57600 - - - - 1 1 247 3.55 1 1 245 1.36 38400 1 1 246 2.34 1 1 243 0.16 1 1 240 1.73 19200 1 1 236 2.34 1 1 230 0.16 1 1 223 1.36 9600 1 1 217 0.16 1 1 204 0.16 1 1 191 0.16 4800 1 1 178 0.16 1 1 152 0.16 1 1 126 0.16 baud rate f per = 12 mhz (2) f per = 16 mhz (2) f per = 20 mhz (2) spd smod1 brl error % spd smod1 brl error % spd smod1 brl error % 115200 - - - - 1 1 247 3.55 1 1 245 1.36 57600 1 1 243 0.16 1 1 239 2.12 1 1 234 1.36 38400 1 1 236 2.34 1 1 230 0.16 1 1 223 1.36 19200 1 1 217 0.16 1 1 204 0.16 1 1 191 0.16 9600 1 1 178 0.16 1 1 152 0.16 1 1 126 0.16 4800 1 1 100 0.16 1 1 48 0.16 1 0 126 0.16 0 1 smod1 pcon.7 per clock y 2 y 16 to serial port
175 at8xc51snd2c 4341e?mp3?06/05 figure 127. baud rate formula (mode 2) multiprocessor communication (modes 2 and 3) modes 2 and 3 provide a ninth-bit mode to fa cilitate multiprocessor communication. to enable this feature, set sm2 bit in scon register. when the multiprocessor communica- tion feature is enabled, the serial port can differentiate between dat a frames (ninth bit clear) and address frames (ninth bit set). th is allows the at8xc51snd2c to function as a slave processor in an environment where multiple slave processors share a single serial line. when the multiprocessor communication featur e is enabled, the receiver ignores frames with the ninth bit clear. the receiver exam ines frames with the ninth bit set for an address match. if the received address matc hes the slaves address, the receiver hard- ware sets rb8 and ri bits in scon register, generating an interrupt. the addressed slave?s software then clears sm2 bit in scon register and prepares to receive the data bytes. the other slaves are unaffected by these data bytes because they are waiting to respond to their own addresses. automatic address recognition the automatic address recognition feature is enabled when the multiprocessor commu- nication feature is enabled (sm2 bit in scon register is set). implemented in hardware, automatic address recognition enhances the multiprocessor communication feature by allowing the serial port to examine the address of each incoming command frame. only when the serial port recognizes its own address, the receiver sets ri bit in scon register to gene rate an interrupt. this ensures that the cpu is not interrupted by command frames addressed to other devices. if desired, the automatic address recognition feature in mode 1 may be enabled. in this configuration, the stop bit takes the place of the ninth data bit. bit ri is set only when the received command frame address matches the device?s address and is terminated by a valid stop bit. to support automatic address recognition, a device is identified by a given address and a broadcast address. note: the multiprocessor communication and automatic address recognition features cannot be enabled in mode 0 (i.e, setting sm2 bit in scon register in mode 0 has no effect). given address each device has an individual address that is specified in saddr register; the saden register is a mask byte that contains don?t care bits (defined by zeros) to form the device?s given address. the don?t care bits provide the flexibility to address on e or more slaves at a time. the following example illu strates how a given address is formed. to address a device by its individual address, the saden mask byte must be 1111 1111b . for example: saddr = 0101 0110b saden = 1111 1100b given = 0101 01xxb baud_rate= 32 2 smod1 ? f per
176 at8xc51snd2c 4341e?mp3?06/05 the following is an example of how to use gi ven addresses to address different slaves: slave a:saddr = 1111 0001b saden = 1111 1010b given = 1111 0x0xb slave b:saddr = 1111 0011b saden = 1111 1001b given = 1111 0xx1b slave c:saddr = 1111 0011b saden = 1111 1101b given = 1111 00x1b the saden byte is selected so that each slave may be addressed separately. for slave a, bit 0 (the lsb) is a don?t-care bi t; for slaves b and c, bit 0 is a 1. to com- municate with slave a only, the master must send an address where bit 0 is clear (e.g. 1111 0000b ). for slave a, bit 1 is a 0; for slaves b and c, bit 1 is a don?t care bit. to communicate with slaves a and b, but not slave c, the master must send an address with bits 0 and 1 both set (e.g. 1111 0011b ). to communicate with slaves a, b and c, the master must send an address with bit 0 set, bit 1 clear, and bit 2 clear (e.g. 1111 0001b ). broadcast address a broadcast address is formed from the logical or of the saddr and saden registers with zeros defined as don?t-care bits, e.g.: saddr = 0101 0110b saden = 1111 1100b (saddr | saden)=1111 111xb the use of don?t-care bits pr ovides flexibility in defining th e broadcast address, however in most applications, a broadcast address is ffh. the following is an example of using broadcast addresses: slave a:saddr = 1111 0001b saden = 1111 1010b given = 1111 1x11b, slave b:saddr = 1111 0011b saden = 1111 1001b given = 1111 1x11b, slave c:saddr = 1111 0010b saden = 1111 1101b given = 1111 1111b, for slaves a and b, bit 2 is a don?t care bit; for slave c, bit 2 is set. to communicate with all of the slaves, the master must send the address ffh. to communicate with slaves a and b, bu t not slave c, the master must send the address fbh. reset address on reset, the saddr and saden registers ar e initialized to 00h, i.e. the given and broadcast addresses are xxxx xxxxb (all don?t care bits). this ensures that the serial port is backwards compatible with the 80c51 microcontrollers that do not support auto- matic address recognition.
177 at8xc51snd2c 4341e?mp3?06/05 interrupt the serial i/o port handles 2 interrupt sour ces that are the ?end of reception? (ri in scon) and ?end of transmission? (ti in sc on) flags. as shown in figure 128 these flags are combined together to appear as a single interrupt source for the c51 core. flags must be cleared by software when exec uting the serial interrupt service routine. the serial interrupt is enabled by setting es bit in ien0 register. this assumes interrupts are globally enabled by setting ea bit in ien0 register. depending on the selected mode and weather the framing error detec tion is enabled or disabled, ri flag is set during the stop bit or during the ninth bit as detailed in figure 129. figure 128. serial i/o interrupt system figure 129. interrupt waveforms es ien0.4 serial i/o interrupt request ti scon.1 ri scon.0 rxd d0d1d2d3d4d5d6d7 start bit 8-bit data stop bit ri smod0 = x fe smod0 = 1 a. mode 1 b. mode 2 and 3 rxd d0d1d2d3d4d5d6 d8 start bit 9-bit data stop bit ri smod0 = 1 fe smod0 = 1 d7 ri smod0 = 0
178 at8xc51snd2c 4341e?mp3?06/05 registers table 160. scon register scon (s:98h) ? serial control register reset value = 0000 0000b 76543210 fe/sm0 ovr/sm1 sm2 ren tb8 rb8 ti ri bit number bit mnemonic description 7 fe framing error bit to select this function, set smod0 bit in pcon register. set by hardware to indicate an invalid stop bit. must be cleared by software. sm0 serial port mode bit 0 refer to table 158 for mode selection. 6sm1 serial port mode bit 1 refer to table 158 for mode selection. 5sm2 serial port mode bit 2 set to enable the multiprocessor communication and automatic address recognition features. clear to disable the multiprocessor communication and automatic address recognition features. 4ren receiver enable bit set to enable reception. clear to disable reception. 3tb8 transmit bit 8 modes 0 and 1: not used. modes 2 and 3: software writes the ninth data bit to be transmitted to tb8. 2rb8 receiver bit 8 mode 0: not used. mode 1 (sm2 cleared): set or cleared by hardware to reflect the stop bit received. modes 2 and 3 (sm2 set): set or cleared by hardware to reflect the ninth bit received. 1ti transmit interrupt flag set by the transmitter after the last data bit is transmitted. must be cleared by software. 0ri receive interrupt flag set by the receiver after the stop bit of a frame has been received. must be cleared by software.
179 at8xc51snd2c 4341e?mp3?06/05 table 161. sbuf register sbuf (s:99h) ? serial buffer register reset value = xxxx xxxxb table 162. saddr register saddr (s:a9h) ? slave individual address register reset value = 0000 0000b table 163. saden register saden (s:b9h) ? slave individ ual address mask byte register reset value = 0000 0000b 76543210 sd7 sd6 sd5 sd4 sd3 sd2 sd1 sd0 bit number bit mnemonic description 7 - 0 sd7:0 serial data byte read the last data received by the serial i/o port. write the data to be transmitted by the serial i/o port. 76543210 sad7 sad6 sad5 sad4 sad3 sad2 sad1 sad0 bit number bit mnemonic description 7 - 0 sad7:0 slave individual address 76543210 sae7 sae6 sae5 sae4 sae3 sae2 sae1 sae0 bit number bit mnemonic description 7 - 0 sae7:0 slave address mask byte
180 at8xc51snd2c 4341e?mp3?06/05 table 164. bdrcon register bdrcon (s:92h) ? baud rate generator control register reset value = xxx0 0000b table 165. brl register brl (s:91h) ? baud rate generator reload register reset value = 0000 0000b 76543210 - - - brr tbck rbck spd m0src bit number bit mnemonic description 7 - 5 - reserved the value read from these bits are indeterminate. do not set these bits. 4brr baud rate run bit set to enable the baud rate generator. clear to disable the baud rate generator. 3tbck transmission baud rate selection bit set to select the baud rate generator as transmission baud rate generator. clear to select the timer 1 as transmission baud rate generator. 2rbck reception baud rate selection bit set to select the baud rate generator as reception baud rate generator. clear to select the timer 1 as reception baud rate generator. 1 spd baud rate speed bit set to select high speed baud rate generation. clear to select low speed baud rate generation. 0m0src mode 0 baud rate source bit set to select the variable baud rate generator in mode 0. clear to select fixed baud rate in mode 0. 76543210 brl7 brl6 brl5 brl4 brl3 brl2 brl1 brl0 bit number bit mnemonic description 7 - 0 brl7:0 baud rate reload value
181 at8xc51snd2c 4341e?mp3?06/05 two-wire interface (twi) controller the at8xc51snd2c implements a twi controller supporting the four standard master and slave modes with multimaste r capability. thus, it allows connection of slave devices like lcd controller, audio dac, etc., but also external master controlling where the at8xc51snd2c is used as a peripheral of a host. the twi bus is a bi-directional twi serial communication standard. it is designed prima- rily for simple but efficient integrated circuit control. the system is comprised of 2 lines, scl (serial clock) and sda (serial data) that carry information between the ics con- nected to them. the serial data transfer is limited to 100 kbit/s in low speed mode, however, some higher bit rates can be achi eved depending on th e oscillator frequency. various communication configurations can be designed using this bus. figure 130 shows a typical twi bus configuration using the at8xc51snd2c in master and slave modes. all the devices connected to the bus can be master and slave. figure 130. typical twi bus configuration description the cpu interfaces to the twi logic via the following four 8-bit special function regis- ters: the synchronous serial control register (sscon sfr, see table 174), the synchronous serial data register (ssd at sfr, see table 176), the synchronous serial status register (sssta sfr, see table 175) and the synchronous serial address register (ssadr sfr, see table 177). sscon is used to enable the controller, to program the bit rate (see table 174), to enable slave modes, to acknowledge or not a received data, to send a start or a stop condition on the twi bus, and to acknowledge a serial interrupt. a hardware reset disables the twi controller. sssta contains a status code which reflects the status of the twi logic and the twi bus. the three least significant bits are always zero. the five most significant bits con- tains the status code. there are 26 possib le status codes. when sssta contains f8h, no relevant state information is available and no serial interrupt is requested. a valid sta- tus code is available in sssta after ssi is set by hardware and is still present until ssi has been reset by software. table 167 to tabl e 135 give the status for both master and slave modes and miscellaneous states. ssdat contains a byte of serial data to be transmitted or a byte which has just been received. it is addressable while it is not in process of shifting a byte. this occurs when twi logic is in a defined state and the serial interrupt flag is set. data in ssdat remains stable as long as ssi is set. while data is being shifted out, data on the bus is simulta- neously shifted in; ssdat always contains the last byte present on the bus. ssadr may be loaded with the 7 - bit slave a ddress (7 most signif icant bits) to which the controller will respond when programmed as a slave tr ansmitter or receiver. the lsb is used to enable general call address (00h) recognition. figure 131 shows how a data transfer is accomplished on the twi bus. at8xc51snd2c master/slave lcd display audio dac scl sda rp rp host microprocessor scl sda
182 at8xc51snd2c 4341e?mp3?06/05 figure 131. complete data tran sfer on twi bus the four operating modes are: ? master transmitter ? master receiver ? slave transmitter ? slave receiver data transfer in each mode of operation are shown in figure 132 through figure 135. these figures contain the following abbreviations: a acknowledge bit (low level at sda) a not acknowledge bit (high level on sda) data 8-bit data byte s start condition p stop condition mr master receive mt master transmit sla slave address gca general call address (00h) r read bit (high level at sda) w write bit (low level at sda) in figure 132 through figure 135, circles are used to indicate when the serial interrupt flag is set. the numbers in the circles show the status code held in sssta. at these points, a service routine must be executed to continue or complete the serial transfer. these service routines are not critical si nce the serial transfer is suspended until the serial interrupt flag is cleared by software. when the serial interr upt routine is entered, the status code in sssta is used to branch to the appropriate service routine. for each status code, the required software action and details of the following serial transfer are given in table 167 through table 135. s slave address scl sda msb r/w direction ack signal nth data byte ack signal p/s bit from receiver from receiver 12 89 12 89 clock line held low while serial interrupts are serviced
183 at8xc51snd2c 4341e?mp3?06/05 bit rate the bit rate can be selected from seven predefined bit rates or from a programmable bit rate generator using the sscr2, sscr1, and sscr0 control bits in sscon (see table 174). the predefined bit rates are derived from the peripheral clock (f per ) issued from the clock cont roller block as detailed in section "oscillator", page 12, while bit rate generator is based on timer 1 overflow output. note: 1. these bit rates are outside of the low speed standard specification limited to 100 khz but can be used with high speed twi components limited to 400 khz. master transmitter mode in the master transmitter mode, a number of data bytes are transmitted to a slave receiver (see figure 132). before the master transmitter mode can be entered, sscon must be initialized as follows: sscr2:0 define the serial bit rate (see table 166). sspe mu st be set to e nable the con- troller. sssta, sssto and ssi must be cleared. the master transmitter mode may now be ent ered by setting the sssta bit. the twi logic will now monitor the twi bus and generat e a start condition as soon as the bus becomes free. when a start condition is trans mitted, the serial interrupt flag (ssi bit in sscon) is set, and the status code in sssta is 08h. this st atus must be used to vector to an interrupt routine that loads ssdat with the slave address and the data direction bit (sla+w). the se rial interrupt flag (ssi) must then be cleared before the serial transfer can continue. when the slave address and the direction bit have been transmitted and an acknowl- edgment bit has been received , ssi is set again and a numb er of status code in sssta are possible. there are 18h, 20h or 38h for the master mode and also 68h, 78h or b0h if the slave mode was enabled (ssaa = logic 1). the appropriate action to be taken for each of these status code is detailed in table 167. this scheme is repeated until a stop condition is transmitted. sspe and sscr2:0 are not affected by the serial transfer and are not re ferred to in table 167. after a repeated start condition (state 10h) the controller may switch to the master receiver mode by loading ssdat with sla+r. table 166. serial clock rates sscrx bit frequency (khz) f per divided by 210 f per = 6 mhz f per = 8 mhz f per = 10 mhz 0 0 0 47 62.5 78.125 128 0 0 1 53.5 71.5 89.3 112 0 1 0 62.5 83 104.2 (1) 96 0 1 1 75 100 125 (1) 80 1 0 0 12.5 16.5 20.83 480 1 0 1 100 133.3 (1) 166.7 (1) 60 110 200 (1) 266.7 (1) 333.3 (1) 30 1 1 1 0.5 < ? < 125 (1) 0.67 < ? < 166.7 (1) 0.81 < ? < 208.3 (1) 96 ? (256 ? reload value timer 1) sscr2 sspe sssta sssto ssi ssaa sscr1 sscr0 bit rate 1 0 0 0 x bit rate bit rate
184 at8xc51snd2c 4341e?mp3?06/05 master receiver mode in the master receiver mode, a number of data bytes are received from a slave transmit- ter (see figure 133). the transfer is initia lized as in the master transmitter mode. when the start condition has been transmitted, th e interrupt routine must load ssdat with the 7 - bit slave address and the data direct ion bit (sla+r). the serial interrupt flag (ssi) must then be cleared before the serial transfer can continue. when the slave address and the direction bit have been transmitted and an acknowl- edgment bit has been received, the serial interrupt flag is set again and a number of status code in sssta are possible. there are 40h, 48h or 38h for the master mode and also 68h, 78h or b0h if the slave mode was enabled (ssaa = logi c 1). the appropriate action to be taken for each of these status code is detailed in table 135. this scheme is repeated until a stop condition is transmitted. sspe and sscr2:0 are not affected by the serial transfer and are not re ferred to in table 135. after a repeated start condition (state 10h) the controller may switch to the master transmitter mode by loading ssdat with sla+w. slave receiver mode in the slave receiver mode, a number of data bytes are received from a master transmit- ter (see figure 134). to initiate the slave receiver mode, ssadr and sscon must be loaded as follows: the upper 7 bits are the addresses to wh ich the controller will respond when addressed by a master. if the lsb (ssgc) is set, t he controller will resp ond to the general call address (00h); otherwise, it ignores the general call address. sscr2:0 have no effect in the slave mode. sspe must be set to enable the controller. the ssaa bit must be set to enable the ow n slave address or the general call address acknowledgment. sssta, sssto and ssi must be cleared. when ssadr and sscon have been initializ ed, the controller waits until it is addressed by its own slave address followed by the data direction bit which must be logic 0 (w) for operating in the slave receiv er mode. after its own slave address and the w bit has been received, the serial interrupt flag is set and a vali d status code can be read from sssta. this status co de is used to vector to an interrupt serv ice routine, and the appropriate action to be taken for each of these status code is detailed in table 135 and table 171. the slave receiver mode may also be entered if arbitration is lost while the controller is in the master mode (see states 68h and 78h). if the ssaa bit is reset during a transfer, the controller will return a not acknowledge (logic 1) to sda after the next received data byte. while ssaa is reset, the controller does not respond to its own slave address. however, the twi bus is still monitored and address recogniti on may be resumed at any time by setting ssaa. this means that the ssaa bit may be used to temporarily isol ate the controller from the twi bus. ssa6 ssa5 ssa4 ssa3 ssa2 ssa1 ssa0 ssgc m own slave address o x sscr2 sspe sssta sssto ssi ssaa sscr1 sscr0 x10001xx
185 at8xc51snd2c 4341e?mp3?06/05 slave transmitter mode in the slave transmitter mode, a number of data bytes are transmitted to a master receiver (see figure 135). data transfer is initialized as in the slave receiver mode. when ssadr and sscon have been initializ ed, the controller waits until it is addressed by its own slave address followed by the data direction bit which must be logic 1 (r) for operating in the slave transmitter mode. after its own slave address and the r bit have been received, the serial interr upt flag is set and a valid status code can be read from sssta. this status code is used to vector to an interrupt service routine, and the appropriate action to be taken for each of these status code is detailed in table 171. the slave transmitter mode may also be entered if arbitration is lost while the controller is in the master mode (see state b0h). if the ssaa bit is reset during a transfer, the controller will transmit the last byte of the transfer and enter state c0h or c8h. the controller is switched to the not addressed slave mode and will ignore the ma ster receiver if it continue s the transfer. thus the mas- ter receiver receives all 1?s as serial dat a. while ssaa is reset, the controller does not respond to its own sl ave address. however, the twi bus is still mo nitored and address recognition may be resumed at any time by setting ssaa. this means that the ssaa bit may be used to temporarily isolate the controller from the twi bus. miscellaneous states there are 2 sssta codes that do not corres pond to a defined twi hardware st ate (see table 172). these are discussed below. status f8h indicates that no relevant informat ion is available because the serial interrupt flag is not yet set. this occurs between ot her states and when the controller is not involved in a serial transfer. status 00h indicates that a bus error has occu rred during a serial transfer. a bus error is caused when a start or a stop condition occurs at an ille gal position in the format frame. examples of such illegal positions are during the serial transfer of an address byte, a data byte, or an acknowledge bit. when a bus error occurs, ssi is set. to recover from a bus error, th e sssto flag must be set and ssi must be cleared. this causes the controller to ent er the not addressed slave mode and to clear the sssto flag (no other bits in s1con are affected). the sda and scl lines are released and no stop condition is transmitted. note: the twi controller interfaces to the exte rnal twi bus via 2 port 1 pins: p1.6/scl (serial clock line) and p1.7/sda (serial data line). to avoid low level asserting and conflict on these lines when the twi controller is enabled, the output latches of p1.6 and p1.7 must be set to logic 1.
186 at8xc51snd2c 4341e?mp3?06/05 figure 132. format and states in the master transmitter mode data 20h a sla 08h mt mr successful transmis- sion to a slave receiver next transfer started with a repeated start condition not acknowledge received after the slave address arbitration lost in slave address or data byte arbitration lost and addressed as slave not acknowledge received data a from master to slave from slave to master any number of data bytes and their associated acknowledge bits this number (contain ed in sssta) corresponds to a defined state of the twi bus sw 18h a p 28h sla sw r a p 10h 30h a p 38h a or a continues other master 38h a or a continues other master 68h a continues other master 78h b0h nnh after a data byte to corresponding states in slave mode
187 at8xc51snd2c 4341e?mp3?06/05 figure 133. format and states in the master receiver mode a data 48h a sla 08h mr mt successful reception from a slave transmitter next transfer started with a repeated start condition not acknowledge received after the slave address arbitration lost in slave address or data byte arbitration lost and addressed as slave data a from master to slave from slave to master any number of data bytes and their associated acknowledge bits this number (contained in sssta) corresponds to a defined state of the twi bus sr 40h a p 58h sla sr w a p 10h 38h a continues other master 38h a or a continues other master 68h a continues other master 78h b0h nnh to corresponding states in slave mode data 50h
188 at8xc51snd2c 4341e?mp3?06/05 figure 134. format and states in the slave receiver mode a data 68h a sla reception of the own slave address and one or more last data byte received is not acknowledged arbitration lost as master and addressed as slave reception of the general call address and one or more data bytes arbitration lost as master and addressed as slave by general call data a from master to slave from slave to master any number of data bytes and their associated acknowledge bits this number (contained in sssta) corresponds to a defined state of the twi bus sw 60h a p or s 80h a nnh data 80h a0h 88h a p or s a data 78h a general call 70h a p or s 90h a data 90h a0h 98h a p or s data bytes. all are acknowledged last data byte received is not acknowledged
189 at8xc51snd2c 4341e?mp3?06/05 figure 135. format and states in the slave transmitter mode a data b0h a sla data a from master to slave from slave to master any number of data bytes and their associated acknowledge bits this number (contained in sssta) corresponds to a defined state of the twi bus sr a8h a p or s c0h all 1?s ap or s c8h nnh data b8h a arbitration lost as master and addressed as slave reception of the own slave address and transmission of one or more data bytes. last data byte transmitted. switched to not addressed slave (ssaa = 0).
190 at8xc51snd2c 4341e?mp3?06/05 table 167. status for master transmitter mode status code sssta status of the twi bus and twi hardware application software response next action taken by twi hardware to/from ssdat to sscon sssta sssto ssi ssaa 08h a start condition has been transmitted write sla+w x00x sla+w will be transmitted. 10h a repeated start condition has been transmitted write sla+w write sla+r x x 0 0 0 0 x x sla+w will be transmitted. sla+r will be transmitted. logic will switch to master receiver mode 18h sla+w has been transmitted; ack has been received write data byte no ssdat action no ssdat action no ssdat action 0 1 0 1 0 0 1 1 0 0 0 0 x x x x data byte will be transmitted. repeated start will be transmitted. stop condition will be transmitted and sssto flag will be reset. stop condition followed by a start condition will be transmitted and sssto flag will be reset. 20h sla+w has been transmitted; not ack has been received write data byte no ssdat action no ssdat action no ssdat action 0 1 0 1 0 0 1 1 0 0 0 0 x x x x data byte will be transmitted. repeated start will be transmitted. stop condition will be transmitted and sssto flag will be reset. stop condition followed by a start condition will be transmitted and sssto flag will be reset. 28h data byte has been transmitted; ack has been received write data byte no ssdat action no ssdat action no ssdat action 0 1 0 1 0 0 1 1 0 0 0 0 x x x x data byte will be transmitted. repeated start will be transmitted. stop condition will be transmitted and sssto flag will be reset. stop condition followed by a start condition will be transmitted and sssto flag will be reset. 30h data byte has been transmitted; not ack has been received write data byte no ssdat action no ssdat action no ssdat action 0 1 0 1 0 0 1 1 0 0 0 0 x x x x data byte will be transmitted. repeated start will be transmitted. stop condition will be transmitted and sssto flag will be reset. stop condition followed by a start condition will be transmitted and sssto flag will be reset. 38h arbitration lost in sla+w or data bytes no ssdat action no ssdat action 0 1 0 0 0 0 x x twi bus will be released and not addressed slave mode will be entered. a start condition will be transmitted when the bus becomes free.
191 at8xc51snd2c 4341e?mp3?06/05 table 168. status for master receiver mode status code sssta status of the twi bus and twi hardware application software response next action taken by twi hardware to/from ssdat to sscon sssta sssto ssi ssaa 08h a start condition has been transmitted write sla+r x00x sla+r will be transmitted. 10h a repeated start condition has been transmitted write sla+r write sla+w x x 0 0 0 0 x x sla+r will be transmitted. sla+w will be transmitted. logic will switch to master transmitter mode. 38h arbitration lost in sla+r or not ack bit no ssdat action no ssdat action 0 1 0 0 0 0 x x twi bus will be released and not addressed slave mode will be entered. a start condition will be transmitted when the bus becomes free. 40h sla+r has been transmitted; ack has been received no ssdat action no ssdat action 0 0 0 0 0 0 0 1 data byte will be received and not ack will be returned. data byte will be received and ack will be returned. 48h sla+r has been transmitted; not ack has been received no ssdat action no ssdat action no ssdat action 1 0 1 0 1 1 0 0 0 x x x repeated start will be transmitted. stop condition will be transmitted and sssto flag will be reset. stop condition followed by a start condition will be transmitted and sssto flag will be reset. 50h data byte has been received; ack has been returned read data byte read data byte 0 0 0 0 0 0 0 1 data byte will be received and not ack will be returned. data byte will be received and ack will be returned. 58h data byte has been received; not ack has been returned read data byte read data byte read data byte 1 0 1 0 1 1 0 0 0 x x x repeated start will be transmitted. stop condition will be transmitted and sssto flag will be reset. stop condition followed by a start condition will be transmitted and sssto flag will be reset.
192 at8xc51snd2c 4341e?mp3?06/05 table 169. status for slave receiver mode with own slave address status code sssta status of the twi bus and twi hardware application software response next action taken by twi hardware to/from ssdat to sscon sssta sssto ssi ssaa 60h own sla+w has been received; ack has been returned no ssdat action no ssdat action x x 0 0 0 0 0 1 data byte will be received and not ack will be returned. data byte will be received and ack will be returned. 68h arbitration lost in sla+r/w as master; own sla+w has been received; ack has been returned no ssdat action no ssdat action x x 0 0 0 0 0 1 data byte will be received and not ack will be returned. data byte will be received and ack will be returned. 80h previously addressed with own sla+w; data has been received; ack has been returned read data byte read data byte x x 0 0 0 0 0 1 data byte will be received and not ack will be returned. data byte will be received and ack will be returned. 88h previously addressed with own sla+w; data has been received; not ack has been returned read data byte read data byte read data byte read data byte 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 switched to the not addressed slave mode; no recognition of own sla or gca. switched to the not addressed slave mode; own sla will be recognized; gc a will be recognized if ssgc = logic 1. switched to the not addressed slave mode; no recognition of own sla or gca. a start condition will be transmitted when the bus becomes free. switched to the not addressed slave mode; own sla will be recognized; gc a will be recognized if ssgc = logic 1. a start condition will be transmitted when the bus becomes free. a0h a stop condition or repeated start condition has been received while still addressed as slave no ssdat action no ssdat action no ssdat action no ssdat action 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 switched to the not addressed slave mode; no recognition of own sla or gca. switched to the not addressed slave mode; own sla will be recognized; gc a will be recognized if ssgc = logic 1. switched to the not addressed slave mode; no recognition of own sla or gca. a start condition will be transmitted when the bus becomes free. switched to the not addressed slave mode; own sla will be recognized; gc a will be recognized if ssgc = logic 1. a start condition will be transmitted when the bus becomes free.
193 at8xc51snd2c 4341e?mp3?06/05 table 170. status for slave receiver mode with general call address status code sssta status of the twi bus and twi hardware application software response next action taken by twi hardware to/from ssdat to sscon sssta sssto ssi ssaa 70h general call address has been received; ack has been returned no ssdat action no ssdat action x x 0 0 0 0 0 1 data byte will be received and not ack will be returned. data byte will be received and ack will be returned. 78h arbitration lost in sla+r/w as master; general call address has been received; ack has been returned no ssdat action no ssdat action x x 0 0 0 0 0 1 data byte will be received and not ack will be returned. data byte will be received and ack will be returned. 90h previously addressed with general call; data has been received; ack has been returned read data byte read data byte x x 0 0 0 0 0 1 data byte will be received and not ack will be returned. data byte will be received and ack will be returned. 98h previously addressed with general call; data has been received; not ack has been returned read data byte read data byte read data byte read data byte 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 switched to the not addressed slave mode; no recognition of own sla or gca. switched to the not addressed slave mode; own sla will be recognized; gc a will be recognized if ssgc = logic 1. switched to the not addressed slave mode; no recognition of own sla or gca. a start condition will be transmitted when the bus becomes free. switched to the not addressed slave mode; own sla will be recognized; gc a will be recognized if ssgc = logic 1. a start condition will be transmitted when the bus becomes free. a0h a stop condition or repeated start condition has been received while still addressed as slave no ssdat action no ssdat action no ssdat action no ssdat action 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 switched to the not addressed slave mode; no recognition of own sla or gca. switched to the not addressed slave mode; own sla will be recognized; gc a will be recognized if ssgc = logic 1. switched to the not addressed slave mode; no recognition of own sla or gca. a start condition will be transmitted when the bus becomes free. switched to the not addressed slave mode; own sla will be recognized; gc a will be recognized if ssgc = logic 1. a start condition will be transmitted when the bus becomes free.
194 at8xc51snd2c 4341e?mp3?06/05 table 171. status for slave transmitter mode status code sssta status of the twi bus and twi hardware application software response next action taken by twi hardware to/from ssdat to sscon sssta sssto ssi ssaa a8h own sla+r has been received; ack has been returned write data byte write data byte x x 0 0 0 0 0 1 last data byte will be transmitted. data byte will be transmitted. b0h arbitration lost in sla+r/w as master; own sla+r has been received; ack has been returned write data byte write data byte x x 0 0 0 0 0 1 last data byte will be transmitted. data byte will be transmitted. b8h data byte in ssdat has been transmitted; ack has been received write data byte write data byte x x 0 0 0 0 0 1 last data byte will be transmitted. data byte will be transmitted. c0h data byte in ssdat has been transmitted; not ack has been received no ssdat action no ssdat action no ssdat action no ssdat action 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 switched to the not addressed slave mode; no recognition of own sla or gca. switched to the not addressed slave mode; own sla will be recognized; gc a will be recognized if ssgc = logic 1. switched to the not addressed slave mode; no recognition of own sla or gca. a start condition will be transmitted when the bus becomes free. switched to the not addressed slave mode; own sla will be recognized; gc a will be recognized if ssgc = logic 1. a start condition will be transmitted when the bus becomes free. c8h last data byte in ssdat has been transmitted (ssaa= 0); ack has been received no ssdat action no ssdat action no ssdat action no ssdat action 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 switched to the not addressed slave mode; no recognition of own sla or gca. switched to the not addressed slave mode; own sla will be recognized; gc a will be recognized if ssgc = logic 1. switched to the not addressed slave mode; no recognition of own sla or gca. a start condition will be transmitted when the bus becomes free. switched to the not addressed slave mode; own sla will be recognized; gc a will be recognized if ssgc = logic 1. a start condition will be transmitted when the bus becomes free. table 172. status for miscellaneous states status code sssta status of the twi bus and twi hardware application software response next action taken by twi hardware to/from ssdat to sscon sssta sssto ssi ssaa f8h no relevant state information available; ssi = 0 no ssdat action no sscon action wait or proceed current transfer. 00h bus error due to an illegal start or stop condition no ssdat action 010x only the internal hardware is affected, no stop condition is sent on the bus. in all cases, the bus is released and sssto is reset.
195 at8xc51snd2c 4341e?mp3?06/05 registers table 173. auxcon register auxcon (s:90h) ? auxiliary control register reset value = 1111 1111b table 174. sscon register sscon (s:93h) ? synchronous serial control register 76 5 4 3210 sda scl - audcdout audcdin audcclk audccs kin0 bit number bit mnemonic description 7sda twi serial data sda is the bidirectional two wire data line. 6scl twi serial clock when twi controller is in master mode, scl outputs the serial clock to the slave peripherals. when twi controller is in slave mode, scl receives clock from the master controller. 5:1 audio dac control refer to audio dac interface section 0kin0 keyboard input line 76543210 sscr2 sspe sssta sssto ssi ssaa sscr1 sscr0
196 at8xc51snd2c 4341e?mp3?06/05 reset value = 0000 0000b bit number bit mnemonic description 7 sscr2 synchronous serial control rate bit 2 refer to table 166 for rate description. 6sspe synchronous serial peripheral enable bit set to enable the controller. clear to disable the controller. 5 sssta synchronous serial start flag set to send a start condition on the bus. clear not to send a start condition on the bus. 4 sssto synchronous serial stop flag set to send a stop condition on the bus. clear not to send a stop condition on the bus. 3 ssi synchronous serial interrupt flag set by hardware when a serial interrupt is requested. must be cleared by software to acknowledge interrupt. 2ssaa synchronous serial assert acknowledge flag set to enable slave modes. slave modes are entered when sla or gca (if ssgc set) is recognized. clear to disable slave modes. master receiver mode in progress clear to force a not acknowledge (high level on sda). set to force an acknowledge (low level on sda). master transmitter mode in progress this bit has no specific effect when in master transmitter mode. slave receiver mode in progress clear to force a not acknowledge (high level on sda). set to force an acknowledge (low level on sda). slave transmitter mode in progress clear to isolate slave from the bu s after last data byte transmission. set to enable slave mode. 1 sscr1 synchronous serial control rate bit 1 refer to table 166 for rate description. 0 sscr0 synchronous serial control rate bit 0 refer to table 166 for rate description.
197 at8xc51snd2c 4341e?mp3?06/05 table 175. sssta register sssta (s:94h) ? synchronous serial status register reset value = f8h table 176. ssdat register ssdat (s:95h) ? synchronous serial data register reset value = 1111 1111b table 177. ssadr register ssadr (s:96h) ? synchronous serial address register reset value = 1111 1110b 76543210 ssc4 ssc3 ssc2 ssc1 ssc0 0 0 0 bit number bit mnemonic description 7:3 ssc4:0 synchronous serial status code bits 0 to 4 refer to table 167 to table 135 for status description. 2:0 0 always 0. 76543210 ssd7 ssd6 ssd5 ssd4 ssd3 ssd2 ssd1 ssd0 bit number bit mnemonic description 7:1 ssd7:1 synchronous serial address bits 7 to 1 or synchronous serial data bits 7 to 1 0 ssd0 synchronous serial address bit 0 (r/w) or synchronous serial data bit 0 76543210 ssa7 ssa6 ssa5 ssa4 ssa3 ssa2 ssa1 ssgc bit number bit mnemonic description 7:1 ssa7:1 synchronous serial slave address bits 7 to 1 0ssgc synchronous serial general call bit set to enable the general call address recognition. clear to disable the general call address recognition.
198 at8xc51snd2c 4341e?mp3?06/05 keyboard interface the at8xc51snd2c implement a keyboard interface allowing the connection of a key- pad. it is based on one inpu t with programmable interrupt ca pability on both high or low level. this input allows exit from idle and power down modes. description the keyboard interfaces with the c51 core through 2 special function registers: kbcon, the keyboard control register (see tabl e 179); and kbsta, the keyboard control and status register (see table 180). an interrupt enable bit (ekb in ien1 register) allows global enable or disable of the key- board interrupt (see figure 136). as detailed in figure 137 this keyboard input has the capability to detect a programmable level acco rding to kinl0 bit value in kbcon regis- ter. level detection is th en reported in interrupt fl ag kinf0 in kbsta register. a keyboard interrupt is requested each time th is flag is set. this flag can be masked by software using kinm0 bi ts in kbcon register and is cl eared by reading kbsta register. figure 136. keyboard interface block diagram figure 137. keyboard input circuitry power reduction mode kin0 inputs allow exit from idle and powe r-down modes as detailed in section ?power management?, page 46. to enable this feature, kpde bit in kbsta register must be set to logic 1. due to the asynchronous keypad detection in power down mode (all clocks are stopped), exit may happen on parasitic key press. in this case, no key is detected and software must enter power down again. kin0 keyboard interface interrupt request ekb ien1.4 input circuitry kin0 kinm0 kbcon.0 kinf0 kbsta.0 kinl0 kbcon.4 0 1
199 at8xc51snd2c 4341e?mp3?06/05 registers table 178. auxcon register auxcon (s:90h) ? auxiliary control register reset value = 1111 1111b table 179. kbcon register kbcon (s:a3h) ? keyboard control register reset value = 0000 1111b table 180. kbsta register kbsta (s:a4h) ? keyboard co ntrol and status register 76 5 4 3210 sda scl - audcdout audcdin audcclk audccs kin0 bit number bit mnemonic description 7:6 twi lines refer to twi section. 5:1 audio dac control refer to audio dac section. 0kin0 keyboard input interrupt . 76543210 ---kinl0---kinm0 bit number bit mnemonic description 7 - 5 - reserved do not set these bits. 4kinl0 keyboard input level bit set to enable a high level detection on the respective kin0 input. clear to enable a low level detection on the respective kin0 input. 3 - 1 - reserved do not reset these bits. 0 kinm0 keyboard input mask bit set to prevent the respective kinf3:0 fl ag from generating a keyboard interrupt. clear to allow the respective kinf3: 0 flag to generate a keyboard interrupt. 76543210 kpde - - - - - - kinf0 bit number bit mnemonic description 7 kpde keyboard power down enable bit set to enable exit of power down mode by the keyboard interrupt. clear to disable exit of power down mode by the keyboard interrupt.
200 at8xc51snd2c 4341e?mp3?06/05 reset value = 0000 0000b 6 - 1 - reserved the value read from these bits is always 0. do not set these bits. 0kinf0 keyboard input interrupt flag set by hardware when the kin0 input detects a programmed level. cleared when reading kbsta. bit number bit mnemonic description
201 at8xc51snd2c 4341e?mp3?06/05 electrical characteristics absolute maximum rating dc characteristics digital logic storage temperature ......................................... -65 to +150 q c voltage on any other pin to v ss .................................... -0.3 to +4.0 v i ol per i/o pin ................................................................. 5 ma power dissipation ............................................................. 1 w operating conditions ambient temperature under bias........................ -40 to +85 q c v dd ......................................................................................................... 2.7 to 3.3v *notice: stressing the device beyond the ?absolute maxi- mum ratings? may cause permanent damage. these are stress ratings only. operation beyond the ?operating conditions? is not recommended and extended exposure beyond the ?operating conditions? may affect device reliability. table 181. digital dc characteristics v dd = 2.7 to 3.3 v, t a = -40 to +85 q c symbol parameter min typ (1) max units test conditions v il input low voltage -0.5 0.2v dd -0.1 v v ih1 (2) input high voltage (except rst, x1) 0.2v dd +1.1 v dd v v ih2 input high voltage (rst, x1) 0.7v dd v dd +0.5 v v ol1 output low voltage (except p0, ale, mcmd, mdat, mclk, sclk, dclk, dsel, dout) 0.45 v i ol = 1.6 ma v ol2 output low voltage (p0, ale, mcmd, mdat, mclk, sclk, dclk, dsel, dout) 0.45 v i ol = 3.2 ma v oh1 output high voltage (p1, p2, p3, p4 and p5) v dd -0.7 v i oh = -30 p a v oh2 output high voltage (p0, p2 address mode, ale, mcmd, mdat, mclk, sclk, dclk, dsel, dout, d+, d-) v dd -0.7 v i oh = -3.2 ma i il logical 0 input current (p1, p2, p3, p4 and p5) -50 p av in = 0.45 v i li input leakage current (p0, ale, mcmd, mdat, mclk, sclk, dclk, dsel, dout) 10 p a 0.45< v in < v dd i tl logical 1 to 0 transition current (p1, p2, p3, p4 and p5) -650 p av in = 2.0 v r rst pull-down resistor 50 90 200 k : c io pin capacitance 10 pf t a = 25 q c v ret v dd data retention limit 1.8 v
202 at8xc51snd2c 4341e?mp3?06/05 notes: 1. typical values are obtained using v dd = 3 v and t a = 25 q c. they are not tested and there is no guarantee on these values. 2. flash retention is guaranteed with the same formula for v dd min down to 0v. 3. see table 182 for typical consumption in player mode. table 182. typical reference design at89c51snd2c power consumption i dd at89c51snd2c operating current (3) x1 / x2 mode 7/ 11.5 9/ 14.5 10.5 / 18 ma v dd < 3.3 v 12 mhz 16 mhz 20 mhz at83snd2c operating current x1 / x2 mode 7/ 11.5 9/ 14.5 10.5 / 18 ma v dd < 3.3 v 12 mhz 16 mhz 20 mhz i dl at89c51snd2c idle mode current (3) x1 / x2 mode 6.3 / 9.1 7.4 / 11.3 8.5 / 14 ma v dd < 3.3 v 12 mhz 16 mhz 20 mhz at83snd2c idle mode current x1 / x2 mode 6.3 / 9.1 7.4 / 11.3 8.5 / 14 ma v dd < 3.3 v 12 mhz 16 mhz 20 mhz i pd at89c51snd2c power-down mode current 20 500 p av ret < v dd < 3.3 v at83snd2c power-down mode current 20 500 p av ret < v dd < 3.3 v i fp at89c51snd2c flash programming current +15 ma v dd < 3.3 v table 181. digital dc characteristics v dd = 2.7 to 3.3 v, t a = -40 to +85 q c symbol parameter min typ (1) max units test conditions player mode i dd test conditions stop 10 ma at89c51snd2c at 16 mhz, x2 mode, v dd = 3 v no song playing. this consumption does not include audvbat current. playing 37 ma at89c51snd2c at 16 mhz, x2 mode, v dd = 3 v mp3 song with fs= 44.1 khz, at any bit rates (variable bit rate) this consumption does not include audvbat current.
203 at8xc51snd2c 4341e?mp3?06/05 i dd, i dl and i pd test conditions figure 138. i dd test condition, active mode figure 139. i dl test condition, idle mode figure 140. i pd test condition, power-down mode rst tst p0 all other pins are unconnected vdd vdd vdd i dd vdd pvdd uvdd audvdd x2 clock signal vss x1 (nc) vss pvss uvss audvss x2 vdd clock signal rst vss tst x1 p0 (nc) i dl all other pins are unconnected vss vdd vss vdd pvdd uvdd audvdd pvss uvss audvss rst mcmd p0 all other pins are unconnected vss vdd tst mdat vdd i pd vdd pvdd uvdd audvdd x2 vss x1 (nc) vss pvss uvss audvss
204 at8xc51snd2c 4341e?mp3?06/05 oscillator & crystal schematic figure 141. crystal connection note: for operation with most standard crys tals, no external components are needed on x1 and x2. it may be necessary to add external capacitors on x1 and x2 to ground in spe- cial cases (max 10 pf). x1 and x2 may not be used to drive other circuits. parameters table 183. oscillator & crystal characteristics v dd = 2.7 to 3.3 v, t a = -40 to +85 q c phase lock loop schematic figure 142. pll filter connection parameters table 184. pll filter characteristics v dd = 2.7 to 3.3 v, t a = -40 to +85 q c vss x1 x2 q c1 c2 symbol parameter min typ max unit c x1 internal capacitance (x1 - vss) 10 pf c x2 internal capacitance (x2 - vss) 10 pf c l equivalent load capacitance (x1 - x2) 5 pf dl drive level 50 p w f crystal frequency 20 mhz rs crystal series resistance 40 : cs crystal shunt capacitance 6 pf vss filt r c1 c2 vss symbol parameter min typ max unit r filter resistor 100 : c1 filter capacitance 1 10 nf c2 filter capacitance 2 2.2 nf
205 at8xc51snd2c 4341e?mp3?06/05 usb connection schematic figure 143. usb connection parameters table 185. usb termination characteristics v dd = 3 to 3.3 v, t a = -40 to +85 q c dac and pa electrical specifications pa audvbat = 3.6v, ta = 25c unless otherwise noted. high power mode, 100nf capacitor connect ed between cbp and au dvss, 470nf input capacitors, load = 8 ohms. figure 144. pa specification d+ d- vbus gnd d+ d- vss to p o w e r r usb r usb vdd supply r fs symbol parameter min typ max unit r usb usb termination resistor 27 : r fs usb full speed resistor 1.5 k : symbol parameter conditions min typ max unit audvbat supply voltage 3.2 - 5.5 v i dd quiescent current inputs shorted, no load - 6 8 ma i ddstby standby current capacitance - - 2 p a v cbp dc reference - audvbat/2 - v vos output differential offset full gain -20 0 20 mv z in input impedance active state 12k 20k 30k w z lfp output load full power mode 6 8 32 w z llp output load low-power mode 100 150 300 w c l capacitive load - - 100 pf psrr power supply rejection ratio 200 ? 2khz differential output -60 -db bw output frequency bandwidth 1khz reference frequency 3db attenuation. 470nf input coupling capacitors 50 - 20000 hz
206 at8xc51snd2c 4341e?mp3?06/05 figure 145. maximum dissipated power versus power supply t up output setup time off to on mode. voltage already settled. input capacitors precharged -- 10ms v n output noise max gain, a weighted - 120 500 v rms thd hp output distortion high power mode, v dd = 3.2v, 1khz, pout=100mw, gain=0db -50 -db thd lp output distortion low power mode, vdd = 3.2v , 1khz, vout= 100mvpp, max gain, load 8 ohms in serie with 200 ohms -1 -% g acc overall gain accuracy -2 0 2 db g step gain step accuracy -0.7 0 0.7 db symbol parameter conditions min typ max unit 200 250 300 350 400 450 500 550 600 3,2 3,4 3,6 3,8 4 4,2 supply voltage audvbat [v] dissipated power [mw] 8 ohms load 6.5 ohms load
207 at8xc51snd2c 4341e?mp3?06/05 figure 146. dissipated power vs output power, audvbat = 3.2v dac audvdd , hsvdd = 2.8 v, ta=25c, typical case, unless otherwise noted all noise and distortion specif ications are measured in the 20 hz to 0.425xfs and a- weighted filtered. full scale levels scale proportiona lly with the analog supply voltage. figure 147. audio dac specification 0 50 100 150 200 250 300 350 400 450 500 550 600 0 100 200 300 400 500 600 700 800 output power [mw] dissipated power [mw] 8 ohms load 6.5 ohms load overall min typ max units operating temperature -40 +25 +125 c analog supply voltage ( audvdd, hsvdd )2.72.83.3v digital supply voltage ( vdd )2.42.83.3v audio amplifier supply ( audvbat )3.2-5.5v digital inputs/outputs resolution 20 bits logic family cmos logic coding 2?s complement analog performance ? dac to line-out/headphone output output level for full scale input (for audvdd, hsvdd = 2.8 v) 1.65 vpp output common mode voltage 0.5x hsvdd v output load resistance (on hsl , hsr ) - headphone load - line load 16 32 10 ohm kohm
208 at8xc51snd2c 4341e?mp3?06/05 output load capacitance (on hsl , hsr ) - headphone load - line load 30 30 1000 150 pf pf signal to noise ratio (?1dbfs @ 1khz input and 0db gain) - line and headphone loads 87 92 db total harmonic distortion (?1dbfs @ 1khz input and 0db gain) - line load - headphone load - headphone load (16 ohm) -80 -65 -40 -76 -60 db db db dynamic range (measured with -60 dbfs @ 1khz input, extrapolated to full-scale) - line load - headphone load 88 70 93 74 db db interchannel mismatch 0.1 1 db left-channel to right-channel crosstalk (@ 1khz) -90 -80 db output power level control range -6 - 6 db output power level control step 3 db psrr - 1khz - 20khz 55 50 db db maximum output slope at power up (100 to 220f coupling capacitor) 3v/s analog performance ? line-in/microphone input to line-out/headphone output input level for full scale output - 0dbfs level @ audvdd, hsvdd = 2.8 v and 0 db gain @ audvdd, hsvdd = 2.8 v and 20 db gain 1.65 583 0.165 58.3 vpp mvrms vpp mvrms input common mode voltage 0.5x audvd d v input impedance 7 10 kohm signal to noise ratio -1 dbfs @ 1khz input and 0 db gain -21 dbfs @ 1khz input and 20 db gain 81 85 71 db dynamic range (extrapolated to full scale level) -60 dbfs @ 1khz input and 0 db gain -60 dbfs @ 1khz input and 20 db gain 82 86 72 db total harmonic distortion ?1dbfs @ 1khz input and 0 db gain ?1dbfs @ 1khz input and 20 db gain -80 -75 -76 -68 db interchannel mismatch 0.1 1 db overall min typ max units
209 at8xc51snd2c 4341e?mp3?06/05 left-channel to right-channel crosstalk (@ 1khz) -90 -80 db analog performance ? differential mono input amplifier differential input level for full scale output - 0dbfs level @ audvdd, hsvdd = 2.8 v and 0 db gain 1.65 583 vppdif mvrms input common mode voltage 0.5x audvd d v input impedance 7 10 kohm signal to noise ratio (-1 dbfs @ 1khz input and 0 db gain) 76 80 db total harmonic distortion (?1dbfs @ 1khz input and 0 db gain) -85 -81 db analog performance ? pa driver differential output level for full scale input (for audvdd, hsvdd = 3 v) 3.3 vppdif output common mode voltage 0.5x hsvdd v output load 10 30 kohm pf signal to noise ratio (?1dbfs @ 1khz input and 0db gain) 76 80 db total harmonic distortion (?1dbfs @ 1khz input and 0db gain) -75 -71 db master clock master clock maximum long term jitter 1.5 ns pp digital filter performance frequency response (10 hz to 20 khz) +/- 0.1 db deviation from linear phase (10 hz to 20 khz) +/- 0.1 deg passband 0.1 db corner 0.4535 fs stopband 0.5465 fs stopband attenuation 65 db de-emphasis filter performance (for 44.1khz fs) frequency gain margin pass band transition band stop band 0hz to 3180hz 3180hz to 10600hz 10600hz to 20khz -1db logarithm decay -10.45db 1db 1db 1db power performance current consumption fr om audio analog supply avdd , hsvdd in power on 9.5 ma overall min typ max units
210 at8xc51snd2c 4341e?mp3?06/05 current consumption fr om audio analog supply avdd , hsvdd in power down 10 p a power on settling time - from full power down to full power up (audvref and audvcm decoupling capacitors charge) - linein amplifier (line-in coupling capacitors charge) - driver amplifier (out driver dc blocking capacitors charge) 500 50 500 ms ms ms overall min typ max units
211 at8xc51snd2c 4341e?mp3?06/05 digital filters transfer function figure 148. channel filter figure 149. de-emphasis filter 10 3 10 4 -12 -10 -8 -6 -4 -2 0 fre q uenc y ( hz ) gain (db)
212 at8xc51snd2c 4341e?mp3?06/05 audio dac and pa connection figure 150. dac and pa connection audio dac and pa connection audvref auxp painn vss lphn linel liner hsl hsr esdvss ingnd cbp hpn painp hpp audvbat monon monop auxn vdd audvdd audvcm c4 mono input (-) 3v from ldo 3v from ldo 3.2v to 5.5v battery mono differential input c7 8 ohm loud speaker c11 32 ohm headset or line out c8 c5 c6 c3 32 ohm 32 ohm stereo line input c1 c9 c16 c15 c12 r1 c10 r l mono input (+) hsvdd c17 c18 c19 vss hsvss audvss esdvss audvss audvss audvss audvss audvss audvss vss audvss vss
213 at8xc51snd2c 4341e?mp3?06/05 table 186. dac and pa characteristics in system programming schematic figure 151. isp pull-down connection parameters table 187. isp pull-down characteristics v dd = 2.7 to 3.3 v, t a = -40 to +85 q c symbol parameter typ unit c1 capacitance 470 nf c3 capacitance 470 nf c4 capacitance 470 nf c5 capacitance 100 p f c6 capacitance 100 p f c7 capacitance 100 nf c8 capacitance 470 nf c9 capacitance 100n p f c10 capacitance 10 p f c11 capacitance 10 p f c12 capacitance 470 nf c15 capacitance 470 nf c16 capacitance 22 p f c17 capacitance 100 nf c18 capacitance 100 nf c19 capacitance 100 nf r1 resistor 200 : vss isp r isp symbol parameter min typ max unit r isp isp pull-down resistor 2.2 k :
214 at8xc51snd2c 4341e?mp3?06/05 ac characteristics external program bus cycles definition of symbols table 188. external program bus cycles timing symbol definitions timings test conditions: capacitive load on all pins= 50 pf. table 189. external program bus cycle - read ac timings v dd = 2.7 to 3.3 v, t a = -40 to +85 q c signals conditions a address h high i instruction in l low l ale v valid p psen x no longer valid z floating symbol parameter variable clock standard mode variable clock x2 mode unit min max min max t clcl clock period 50 50 ns t lhll ale pulse width 2t clcl -15 t clcl -15 ns t avll address valid to ale low t clcl -20 0.5t clcl -20 ns t llax address hold after ale low t clcl -20 0.5t clcl -20 ns t lliv ale low to valid instruction 4t clcl -35 2t clcl -35 ns t plph psen pulse width 3t clcl -25 1.5t clcl -25 ns t pliv psen low to valid instruction 3t clcl -35 1.5t clcl -35 ns t pxix instruction hold after psen high 0 0 ns t pxiz instruction float after psen high t clcl -10 0.5t clcl -10 ns t aviv address valid to valid instruction 5t clcl -35 2.5t clcl -35 ns t plaz psen low to address float 10 10 ns
215 at8xc51snd2c 4341e?mp3?06/05 waveforms figure 152. external program bus cycle - read waveforms external data 8-bit bus cycles definition of symbols table 190. external data 8-bit bus cycles timing symbol definitions timings test conditions: capacitive load on all pins= 50 pf. table 191. external data 8-bit bus cycle - read ac timings v dd = 2.7 to 3.3 v, t a = -40 to +85 q c t pliv p2 p0 psen ale t lhll t plph instruction in a15:8 t llpl a7:0 a15:8 t avll t llax t plaz d7:0 t pxix t pxiz d7:0 t pxav instruction in a7:0 d7:0 signals conditions a address h high d data in l low l ale v valid q data out x no longer valid rrd z floating wwr symbol parameter variable clock standard mode variable clock x2 mode unit min max min max t clcl clock period 50 50 ns t lhll ale pulse width 2t clcl -15 t clcl -15 ns t avll address valid to ale low t clcl -20 0.5t clcl -20 ns t llax address hold after ale low t clcl -20 0.5t clcl -20 ns t llrl ale low to rd low 3t clcl -30 1.5t clcl -30 ns
216 at8xc51snd2c 4341e?mp3?06/05 t rlrh rd pulse width 6t clcl -25 3t clcl -25 ns t rhlh rd high to ale high t clcl -20 t clcl +20 0.5t clcl -20 0.5t clcl +20 ns t avdv address valid to valid data in 9t clcl -65 4.5t clcl -65 ns t avrl address valid to rd low 4t clcl -30 2t clcl -30 ns t rldv rd low to valid data 5t clcl -30 2.5t clcl -30 ns t rlaz rd low to address float 0 0 ns t rhdx data hold after rd high 0 0 ns t rhdz instruction float after rd high 2t clcl -25 t clcl -25 ns symbol parameter variable clock standard mode variable clock x2 mode unit min max min max
217 at8xc51snd2c 4341e?mp3?06/05 table 192. external data 8-bit bus cycle - write ac timings v dd = 2.7 to 3.3 v, t a = -40 to +85 q c waveforms figure 153. external data 8-bit bus cycle - read waveforms symbol parameter variable clock standard mode variable clock x2 mode unit min max min max t clcl clock period 50 50 ns t lhll ale pulse width 2t clcl -15 t clcl -15 ns t avll address valid to ale low t clcl -20 0.5t clcl -20 ns t llax address hold after ale low t clcl -20 0.5t clcl -20 ns t llwl ale low to wr low 3t clcl -30 1.5t clcl -30 ns t wlwh wr pulse width 6t clcl -25 3t clcl -25 ns t whlh wr high to ale high t clcl -20 t clcl +20 0.5t clcl -20 0.5t clcl +20 ns t avwl address valid to wr low 4t clcl -30 2t clcl -30 ns t qvwh data valid to wr high 7t clcl -20 3.5t clcl -20 ns t whqx data hold after wr high t clcl -15 0.5t clcl -15 ns t avdv t llax t rhdx t rhdz t avll t avrl p2 p0 rd ale t lhll t rlrh data in a15:8 t rlaz t llrl t rhlh t rldv d7:0 a7:0
218 at8xc51snd2c 4341e?mp3?06/05 figure 154. external data 8-bit bus cycle - write waveforms external ide 16-bit bus cycles definition of symbols table 193. external ide 16-bit bus cycl es timing symbol definitions t whlh t avwl t llax t whqx p2 p0 wr ale t lhll t wlwh a15:8 t avll t qvwh d7:0 data out t llwl a7:0 signals conditions a address h high d data in l low l ale v valid q data out x no longer valid rrd z floating wwr
219 at8xc51snd2c 4341e?mp3?06/05 timings test conditions: capacitive load on all pins= 50 pf. table 194. external ide 16-bit bus cycle - data read ac timings v dd = 2.7 to 3.3 v, t a = -40 to +85 q c table 195. external ide 16-bit bus cycle - data write ac timings v dd = 2.7 to 3.3 v, t a = -40 to +85 q c symbol parameter variable clock standard mode variable clock x2 mode unit min max min max t clcl clock period 50 50 ns t lhll ale pulse width 2t clcl -15 t clcl -15 ns t avll address valid to ale low t clcl -20 0.5t clcl -20 ns t llax address hold after ale low t clcl -20 0.5t clcl -20 ns t llrl ale low to rd low 3t clcl -30 1.5t clcl -30 ns t rlrh rd pulse width 6t clcl -25 3t clcl -25 ns t rhlh rd high to ale high t clcl -20 t clcl +20 0.5t clcl -20 0.5t clcl +20 ns t avdv address valid to valid data in 9t clcl -65 4.5t clcl -65 ns t avrl address valid to rd low 4t clcl -30 2t clcl -30 ns t rldv rd low to valid data 5t clcl -30 2.5t clcl -30 ns t rlaz rd low to address float 0 0 ns t rhdx data hold after rd high 0 0 ns t rhdz instruction float after rd high 2t clcl -25 t clcl -25 ns symbol parameter variable clock standard mode variable clock x2 mode unit min max min max t clcl clock period 50 50 ns t lhll ale pulse width 2t clcl -15 t clcl -15 ns t avll address valid to ale low t clcl -20 0.5t clcl -20 ns t llax address hold after ale low t clcl -20 0.5t clcl -20 ns t llwl ale low to wr low 3t clcl -30 1.5t clcl -30 ns t wlwh wr pulse width 6t clcl -25 3t clcl -25 ns t whlh wr high to ale high t clcl -20 t clcl +20 0.5t clcl -20 0.5t clcl +20 ns t avwl address valid to wr low 4t clcl -30 2t clcl -30 ns t qvwh data valid to wr high 7t clcl -20 3.5t clcl -20 ns t whqx data hold after wr high t clcl -15 0.5t clcl -15 ns
220 at8xc51snd2c 4341e?mp3?06/05 waveforms figure 155. external ide 16-bit bus cy cle - data read waveforms note: 1. d15:8 is written in dat16h sfr. figure 156. external ide 16-bit bus cycle - data write waveforms note: 1. d15:8 is the content of dat16h sfr. spi interface definition of symbols table 196. spi interface timing symbol definitions t avdv t llax t rhdx t rhdz t avll t avrl p2 p0 rd ale t lhll t rlrh data in t rlaz t llrl t rhlh t rldv d7:0 a7:0 data in d15:8 (1) a15:8 t whlh t avwl t llax t whqx p2 p0 wr ale t lhll t wlwh t avll t qvwh d7:0 data out t llwl a7:0 d15:8 (1) data out a15:8 signals conditions cclock hhigh i data in l low o data out v valid x no longer valid z floating
221 at8xc51snd2c 4341e?mp3?06/05 timings test conditions: capacitive load on all pins= 50 pf. table 197. spi interface master ac timing v dd = 2.7 to 3.3 v, t a = -40 to +85 q c note: 1. value of this parameter depends on software. symbol parameter min max unit slave mode t chch clock period 2 t per t chcx clock high time 0.8 t per t clcx clock low time 0.8 t per t slch , t slcl ss low to clock edge 100 ns t ivcl , t ivch input data valid to clock edge 40 ns t clix , t chix input data hold after clock edge 40 ns t clov, t chov output data valid after clock edge 40 ns t clox , t chox output data hold time after clock edge 0 ns t clsh , t chsh ss high after clock edge 0 ns t slov ss low to output data valid 50 ns t shox output data hold after ss high 50 ns t shsl ss high to ss low (1) t ilih input rise time 2 p s t ihil input fall time 2 p s t oloh output rise time 100 ns t ohol output fall time 100 ns master mode t chch clock period 2 t per t chcx clock high time 0.8 t per t clcx clock low time 0.8 t per t ivcl , t ivch input data valid to clock edge 20 ns t clix , t chix input data hold after clock edge 20 ns t clov, t chov output data valid after clock edge 40 ns t clox , t chox output data hold time after clock edge 0 ns t ilih input data rise time 2 p s t ihil input data fall time 2 p s t oloh output data rise time 50 ns t ohol output data fall time 50 ns
222 at8xc51snd2c 4341e?mp3?06/05 waveforms figure 157. spi slave waveforms (sscpha= 0) note: 1. not defined but generally the msb of the character which has just been received. figure 158. spi slave waveforms (sscpha= 1) note: 1. not defined but generally the lsb of the character which has just been received. t slcl t slch t chcl t clch mosi (input) sck (sscpol= 0) (input) ss (input) sck (sscpol= 1) (input) miso (output) t chch t clcx t chcx t ivcl t clix t chix t ivch t chov t clov t chox t clox msb in bit 6 lsb in slave msb out slave lsb out bit 6 t slov (1) t shox t shsl t chsh t clsh t chcl t clch mosi (input) sck (sscpol= 0) (input) ss (input) sck (sscpol= 1) (input) miso (output) t chch t clcx t chcx t ivcl t clix t chix t ivch t clov t chov t clox t chox msb in bit 6 lsb in slave msb out slave lsb out bit 6 t slov (1) t shox t shsl t chsh t clsh t slcl t slch
223 at8xc51snd2c 4341e?mp3?06/05 figure 159. spi master waveforms (sscpha= 0) note: 1. ss handled by software using general purpose port pin. figure 160. spi master waveforms (sscpha= 1) note: 1. ss handled by software using general purpose port pin. mosi (input) sck (sscpol= 0) (output) ss (output) sck (sscpol= 1) (output) miso (output) t chch t clcx t chcx t ivcl t clix t chix t ivch t chov t clov t chox t clox msb in bit 6 lsb in msb out port data lsb out port data bit 6 t chcl t clch mosi (input) sck (sscpol= 0) (output) ss (1) (output) sck (sscpol= 1) (output) miso (output) t chch t clcx t chcx t ivcl t clix t chix t ivch t chov t clov t chox t clox msb in bit 6 lsb in msb out port data lsb out port data bit 6 t chcl t clch
224 at8xc51snd2c 4341e?mp3?06/05 two-wire interface timings table 198. twi interface ac timing v dd = 2.7 to 3.3 v, t a = -40 to +85 q c notes: 1. at 100 kbit/s. at other bit-rates this value is inversely proportional to the bit-rate of 100 kbit/s. 2. determined by the external bus-line ca pacitance and the external bus-line pull-up resistor, this must be < 1 p s. 3. spikes on the sda and scl lines with a duration of less than 3t clcl will be filtered out. maximum capacitance on bus-lines sda and scl= 400 pf. 4. t clcl = t osc = one oscillator clock period. waveforms figure 161. two wire waveforms symbol parameter input m i n max output m i n max t hd ; sta start condition hold time 14t clcl (4) 4.0 p s (1) t low scl low time 16t clcl (4) 4.7 p s (1) t high scl high time 14t clcl (4) 4.0 p s (1) t rc scl rise time 1 p s- (2) t fc scl fall time 0.3 p s0.3 p s (3) t su ; dat1 data set-up time 250 ns 20t clcl (4) - t rd t su ; dat2 sda set-up time (before repeated start condition) 250 ns 1 p s (1) t su ; dat3 sda set-up time (before stop condition) 250 ns 8t clcl (4) t hd ; dat data hold time 0 ns 8t clcl (4) - t fc t su ; sta repeated start set-up time 14t clcl (4) 4.7 p s (1) t su ; sto stop condition set-up time 14t clcl (4) 4.0 p s (1) t buf bus free time 14t clcl (4) 4.7 p s (1) t rd sda rise time 1 p s - (2) t fd sda fall time 0.3 p s0.3 p s (3) ts u ; d at 1 t su ;sta ts u ; d at 2 t hd ;sta t high t low sda (input/output) 0.3 v dd 0.7 v dd t buf t su ;sto 0.7 v dd 0.3 v dd t rd t fd t rc t fc scl (input/output) t hd; dat t su; dat3 start or repeated start condition start condition stop condition repeated start condition
225 at8xc51snd2c 4341e?mp3?06/05 mmc interface definition of symbols table 199. mmc interface timing symbol definitions timings table 200. mmc interface ac timings v dd = 2.7 to 3.3 v, t a = -40 to +85 q c, cl d 100pf (10 cards) waveforms figure 162. mmc input-output waveforms signals conditions cclock hhigh d data in l low o data out v valid x no longer valid symbol parameter min max unit t chch clock period 50 ns t chcx clock high time 10 ns t clcx clock low time 10 ns t clch clock rise time 10 ns t chcl clock fall time 10 ns t dvch input data valid to clock high 3 ns t chdx input data hold after clock high 3 ns t chox output data hold after clock high 5 ns t ovch output data valid to clock high 5 ns t ivch mclk mdat input t chch t clcx t chcx t chcl t clch mcmd input t chix t ovch mdat output mcmd output t chox
226 at8xc51snd2c 4341e?mp3?06/05 audio interface definition of symbols table 201. audio interface timing symbol definitions timings table 202. audio interface ac timings v dd = 2.7 to 3.3 v, t a = -40 to +85 q c, cl d 30pf note: 1. 32-bit format with fs= 48 khz. waveforms figure 163. audio interface waveforms signals conditions cclock hhigh o data out l low s data select v valid x no longer valid symbol parameter min max unit t chch clock period 325.5 (1) ns t chcx clock high time 30 ns t clcx clock low time 30 ns t clch clock rise time 10 ns t chcl clock fall time 10 ns t clsv clock low to select valid 10 ns t clov clock low to data valid 10 ns dclk t chch t clcx t chcx t clch t chcl dsel ddat right left t clsv t clov
227 at8xc51snd2c 4341e?mp3?06/05 flash memory definition of symbols table 203. flash memory timing symbol definitions timings table 204. flash memory ac timing v dd = 2.7 to 3.3 v, t a = -40 to +85 q c waveforms figure 164. flash memory - isp waveforms note: 1. isp must be driven through a pull-down resistor (see section ?in system program- ming?, page 213). figure 165. flash memory - internal busy waveforms external clock drive and logic level references definition of symbols table 205. external clock timing symbol definitions timings table 206. external clock ac timings signals conditions sisp l low r rst v valid b fbusy flag x no longer valid symbol parameter min typ max unit t svrl input isp valid to rst edge 50 ns t rlsx input isp hold after rst edge 50 ns t bhbl flash internal busy (programming) time 10 ms n fcy number of flash write cycles 100k cycle t fdr flash data retention time 10 years rst t svrl isp (1) t rlsx fbusy bit t bhbl signals conditions cclock hhigh l low x no longer valid
228 at8xc51snd2c 4341e?mp3?06/05 v dd = 2.7 to 3.3 v, t a = -40 to +85 q c waveforms figure 166. external clock waveform figure 167. ac testing input/output waveforms note: 1. during ac testing, all inputs are driven at v dd -0.5 v for a logic 1 and 0.45 v for a logic 0. 2. timing measurements are made on all outputs at v ih min for a logic 1 and v il max for a logic 0. figure 168. float waveforms note: for timing purposes, a port pin is no l onger floating when a 100 mv change from load voltage occurs and begins to float when a 100 mv change from the loading v oh /v ol level occurs with i ol /i oh = r 20 ma. symbol parameter min max unit t clcl clock period 50 ns t chcx high time 10 ns t clcx low time 10 ns t clch rise time 3 ns t chcl fall time 3 ns t cr cyclic ratio in x2 mode 40 60 % 0.45 v t clcl v dd - 0.5 v ih1 v il t chcx t clch t chcl t clcx 0.45 v v dd - 0.5 0.7 v dd 0.3 v dd v ih min v il max inputs outputs v load v oh - 0.1 v v ol + 0.1 v v load + 0.1 v v load - 0.1 v timing reference points
229 at8xc51snd2c 4341e?mp3?06/05 ordering information part number memory size supply voltage temperature range max frequency package packing product marking rohs compliant at89c51snd2c-7ftil 64k flash 3v industrial 40 mhz bga100 tray 89c51snd2c-il no at89c51snd2c-7fril 64k flash 3v industrial 40 mhz bga100 reel 89c51snd2c-jl yes at89c51snd2c-7ftul 64k flash 3v green 40 mhz bga100 tray 89c51snd2c-jl yes at89c51snd2c-7frul 64k flash 3v green 40 mhz bga100 reel 89c51snd2c-jl yes at83snd2cxxx-7ftul 64k rom 3v green 40 mhz bga100 tray 83c51snd2c-jl yes at83snd2cxxx-7frul 64k rom 3v green 40 mhz bga100 reel 83c51snd2c-jl yes
230 at8xc51snd2c 4341e?mp3?06/05 package information ctbga100
231 at8xc51snd2c 4341e?mp3?06/05 datasheet change log changes from 4341a - 10/04 to 4341b - 01/05 1. update power amplif ier dc characteristics, section ? electrical characteristics?, page 201. 2. fix minor bugs. 3. update power consumption measures, table 182 on page 202. changes from 4341b - 01/05 to 4341c - 03/05 1. change to hardware security system description. section ? hardware security system?, page 19. changes from 4341c - 03/05 to 4341d - 04/05 1. update to dac gain information, figure 53 on page 81. 2. correction to bga package pinout, figure 2 on page 4. 3. updated ordering information, green product version changed to rohs. (green version not yet available) changes from 4341d - 04/05 to 4341e - 06/05 1. added green packaging information. page 228 2. modified operating conditions, page 1.
table of contents 232 features ............. ................ .............. .............. ............... .............. ........... 1 description .............. ................ ................ ................. ................ ............. 2 typical applications ......... .............. .............. ............... .............. ........... 2 block diagram ................... .............. .............. ............... .............. ........... 3 pin description ........... ................. ................ ................. .............. ........... 4 pinouts ................................................................................................................. 4 signals................................................................................................................... 5 internal pin structure.......................................................................................... 11 clock controller ....... ................ ................. ................ .............. ............ 12 oscillator ............................................................................................................ 12 x2 feature.......................................................................................................... 12 pll ..................................................................................................................... 13 registers ............................................................................................................. 15 program/code memory ......... ................ ................. ................ ............ 17 rom memory architecture ................................................................................. 17 flash memory architecture ................................................................................ 18 hardware security system .. ................................................................................ 19 boot memory execution ..................................................................................... 19 preventing flash corruption............................................................................... 20 registers ............................................................................................................. 21 hardware bytes ................... ................................................................................ 22 data memory ............ ................ ................. ................ .............. ............ 23 internal space .................................................................................................... 23 external space .................................................................................................... 25 dual data pointer ............................................................................................... 27 registers ............................................................................................................ 28 special function registers .. ............... ................. ................ .............. 30 interrupt system ............. .............. .............. .............. .............. ............ 36 interrupt system prio rities .................................................................................. 36 external interrupts .............................................................................................. 39 registers ............................................................................................................. 40 power management ............. ................ ................. ................ .............. 46
233 at8xc51snd2c 4341e?mp3?06/05 reset .................................................................................................................. 46 reset recommendation to prevent flash co rruption ........................................ 47 idle mode ............................................................................................................ 47 power-down mode.................. ............................................................................ 48 registers..............................................................................................................50 timers/counters ....... ................. ................ ................. .............. .......... 51 timer/counter operations .................................................................................. 51 timer clock controller ........................................................................................ 51 timer 0................................................................................................................ 52 timer 1................................................................................................................ 54 interrupt .............................................................................................................. 55 registers..............................................................................................................56 watchdog timer ........... ................ ................. .............. .............. .......... 59 description.......................................................................................................... 59 watchdog clock controller ..... ............................................................................ 59 watchdog operation............................................................................................60 registers..............................................................................................................61 mp3 decoder ............. ................. ................ ................. .............. .......... 62 decoder .............................................................................................................. 62 audio controls .....................................................................................................64 decoding errors.................................................................................................. 64 frame information ...............................................................................................65 ancillary data...................................................................................................... 65 interrupt ...............................................................................................................66 registers..............................................................................................................68 audio output interface ....... .............. .............. .............. .............. ........ 73 description.......................................................................................................... 73 clock generator...................................................................................................74 data converter ................................................................................................... 74 audio buffer ........................................................................................................ 75 mp3 buffer.......................................................................................................... 76 interrupt request ................................................................................................ 76 mp3 song playing .............................................................................................. 76 registers..............................................................................................................78 dac and pa interface ........... ................ ................. ................ ............. 80 dac .................................................................................................................... 80 power amplifier....................................................................................................98 audio supplies and start-up ............................................................................... 99 universal serial bus ........ .............. ............... .............. .............. ........ 102 description.........................................................................................................103
234 at8xc51snd2c 4341e?mp3?06/05 configuration .................................................................................................... 107 read/write data fifo ...................................................................................... 109 bulk/interrupt transactions............................................................................... 110 control transactions......................................................................................... 114 isochronous transactions... ...............................................................................115 miscellaneous ....................................................................................................117 suspend/resume management ........................................................................118 usb interrupt system ....................................................................................... 120 registers............................................................................................................122 ide/atapi interface ............ ................ ................. ................ ............. 132 description........................................................................................................ 132 registers........................................................................................................... 134 multimedia card controller ................ ................. ................ ............. 135 card concept.................................................................................................... 135 bus concept ..................................................................................................... 135 description........................................................................................................ 140 clock generator................................................................................................ 140 command line controller................................................................................. 142 data line controller...........................................................................................144 interrupt .............................................................................................................150 registers............................................................................................................151 synchronous peripheral interface ........... .............. .............. ........... 157 description.........................................................................................................158 interrupt ............................................................................................................ 162 configuration .....................................................................................................163 registers............................................................................................................167 serial i/o port ............... ................ .............. .............. .............. ........... 169 mode selection ................................................................................................. 169 baud rate generator.......... .............................................................................. 169 synchronous mode (mode 0) ........................................................................... 170 asynchronous modes (modes 1, 2 and 3) .........................................................172 multiprocessor communication (modes 2 and 3) ............................................. 175 automatic address recognition................. ....................................................... 175 interrupt .............................................................................................................177 registers............................................................................................................178 two-wire interface (twi) controller .... ................. ................ ........... 181 description........................................................................................................ 181 registers........................................................................................................... 195 keyboard interface .......... .............. ............... .............. .............. ........ 198 description........................................................................................................ 198
235 at8xc51snd2c 4341e?mp3?06/05 registers............................................................................................................199 electrical characteristics ..... ................ ................. ................ ........... 201 absolute maximum rating.. .............................................................................. 201 dc characteristics............................................................................................ 201 ac characteristics ............................................................................................ 214 spi interface ..................................................................................................... 220 ordering information ............ ................ ................. ................ ........... 229 package information ............ ................ ................. ................ ........... 230 ctbga100 ....................................................................................................... 230 datasheet change log.......... ................ ................. ................ .......... 231 changes from 4341a - 10/04 to 4341b - 01/05 ................................................ 231 changes from 4341b - 01/05 to 4341c - 03/05................................................ 231 changes from 4341c - 03/05 to 4341d - 04/05................................................ 231 changes from 4341d - 04/05 to 4341e - 06/05................................................ 231
printed on recycled paper. disclaimer: atmel corporation makes no warranty for the use of its products , other than those expressly contained in the company?s standar d warranty which is detailed in atmel?s terms and conditions locat ed on the company?s web site. the company assumes no responsibi lity for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time wi thout notice, and does not make any commitment to update the information contained her ein. no licenses to patents or other intellectual property of atmel are granted by the company in connection with the sale of atmel produc ts, expressly or by implicati on. atmel?s products are not aut horized for use as critical components in life support devices or systems. atmel corporation atmel operations 2325 orchard parkway san jose, ca 95131, usa tel: 1(408) 441-0311 fax: 1(408) 487-2600 regional headquarters europe atmel sarl route des arsenaux 41 case postale 80 ch-1705 fribourg switzerland tel: (41) 26-426-5555 fax: (41) 26-426-5500 asia room 1219 chinachem golden plaza 77 mody road tsimshatsui east kowloon hong kong tel: (852) 2721-9778 fax: (852) 2722-1369 japan 9f, tonetsu shinkawa bldg. 1-24-8 shinkawa chuo-ku, tokyo 104-0033 japan tel: (81) 3-3523-3551 fax: (81) 3-3523-7581 memory 2325 orchard parkway san jose, ca 95131, usa tel: 1(408) 441-0311 fax: 1(408) 436-4314 microcontrollers 2325 orchard parkway san jose, ca 95131, usa tel: 1(408) 441-0311 fax: 1(408) 436-4314 la chantrerie bp 70602 44306 nantes cedex 3, france tel: (33) 2-40-18-18-18 fax: (33) 2-40-18-19-60 asic/assp/smart cards zone industrielle 13106 rousset cedex, france tel: (33) 4-42-53-60-00 fax: (33) 4-42-53-60-01 1150 east cheyenne mtn. blvd. colorado springs, co 80906, usa tel: 1(719) 576-3300 fax: 1(719) 540-1759 scottish enterprise technology park maxwell building east kilbride g75 0qr, scotland tel: (44) 1355-803-000 fax: (44) 1355-242-743 rf/automotive theresienstrasse 2 postfach 3535 74025 heilbronn, germany tel: (49) 71-31-67-0 fax: (49) 71-31-67-2340 1150 east cheyenne mtn. blvd. colorado springs, co 80906, usa tel: 1(719) 576-3300 fax: 1(719) 540-1759 biometrics/imaging/hi-rel mpu/ high speed converters/rf datacom avenue de rochepleine bp 123 38521 saint-egreve cedex, france tel: (33) 4-76-58-30-00 fax: (33) 4-76-58-34-80 literature requests www.atmel.com/literature 4341e?mp3?06/05 /0m ? atmel corporation 2005. all rights reserved. atmel?, logo and co mbinations thereof, are registered trademarks, and everywhere you are(sm) are the trademarks of atmel corporation or its subsidiaries . other terms and product names may be trademarks of others.


▲Up To Search▲   

 
Price & Availability of AT83SND2C-7FTUL

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X